

Variables are initialized to zero by default unless specified otherwise. Y, z: int // declares y and z to have type `int` X = 1 // `1` is an untyped integer literal which can implicitly convert to `int`Ī variable declaration declares a new variable for the current scope. x: int = 1.0 // A float literal but it can be represented by an integer without precision lossĬonstant literals are “untyped” which means that they can implicitly convert to a type. In Odin, if a number constant can be represented by a type without precision loss, it will automatically convert to that type. A leading zero does not produce an octal constant (unlike C). If a number literal is suffixed with i, it is an imaginary number literal: 2i (2 multiply the square root of -1).īinary literals are prefixed with 0b, octal literals with 0o, and hexadecimal literals with 0x.

A number that contains a dot is a floating point literal: 1.0e9 (one billion). A useful feature in Odin is that underscores are allowed for better readability: 1_000_000_000 (one billion). Numerical literals are written similar to most other programming languages.


My_integer_variable: int // A comment for documentation Single line comments begin with //: // A comment Lexical elements and literals # Comments #Ĭomments can be anywhere outside of a string or character literal.
