HaxeDoc2

(やまだぃちぅ) #1

2.1 Basic Types..........................................


Basic typesareBool,FloatandInt. They can easily be identified in the syntax by values such
as


  • trueandfalseforBool,

  • 1 , 0 ,-1and0xFF0000forIntand

  • 1.0,0.0,-1.0,1e10forFloat.


Basic types are not classes (2.3) in Haxe. They are implemented as abstract types (2.8) and are
tied to the compiler’s internal operator-handling as described in the following sections.

2.1.1 Numeric types


Type: Float
Represents a double-precision IEEE 64-bit floating point number.

Type: Int
Represents an integral number.

While everyIntcan be used where aFloatis expected (that is,Intis assignable toorunifies
withFloat), the reverse is not true: Assigning aFloatto anIntmight lose precision and is not
allowed implicitly.

2.1.2 Overflow.......................................


For performance reasons, the Haxe Compiler does not enforce any overflow behavior. The bur-
den of checking for overflows falls to the target platform. Here are some platform specific notes
on overflow behavior:

C++, Java, C#, Neko, Flash: 32-bit signed integers with usual overflow practices

PHP, JS, Flash 8: No nativeInttype, loss of precision will occur if they reach their float limit (2^52 )

Alternatively, thehaxe.Int32andhaxe.Int64classes can be used to ensure correct overflow
behavior regardless of the platform at the cost of additional computations depending on the
platform.

2.1.3 Numeric Operators.................................


make sure the types
are right for inc, dec,
negate, and bitwise
negate


make sure the types
are right for inc, dec,
negate, and bitwise
negate


While introducing the
different operations,
we should include
that information
as well, including
how they differ with
the ”C” standard, see
http://haxe.org/manual/operators


While introducing the
different operations,
we should include
that information
as well, including
how they differ with
the ”C” standard, see
http://haxe.org/manual/operators


13
Free download pdf