Contents | Index | < Browse | Browse >
2.5 Primitive Types

  AmiBlitz³ knows the following primitive types:

  Name          | Extension | Size   | Value Range
  --------------+-----------+--------+---------------------------------------
  Byte          |       .b  |  8 bit | -128...+127
  Word          |       .w  | 16 bit | -32768...+32767
  Long          |       .l  | 32 bit | -2^31...+2^31-1
  Quick         |       .q  | 32 bit | -32768...+32767 (16.16 bit fix point)
  Float         |       .f  | 32 bit | quite large
  Double Float  |       .d  | 64 bit | even larger
  String        |     .s/$  | 32 bit | character string from 0-2^31-1 length
                |           | +64+(n+1)*8 bit
  Pointer       | *         | 32 bit | 0...2^31-1

  The AmiBlitz³ compiler will throw an error if the types within an
  expression don't match and can't be casted easily.

2.5.1 Byte (.b)
  
  The type Byte is a signed 8 bit integer.

2.5.2 Word (.w)
  
  The type Word is a signed 16 bit integer.
  
2.5.3 Long (.l)
  
  The type Long is a signed 32 bit integer.
  
2.5.4 Quick (.q)
  
  The type Quick is a signed, 16.16 bit fix point. That means, the upper
  16bit are used for the (signed) integer value, and the lower 16 bit are
  used for the fractional part.
  This type is a relict from BlitzBasic for machines that have no floating point
  unit. It is called "Quick" because it is quicker than a software-emulated
  floating point. The accuracy and the value range is pretty low, but well
  enough for coordinates of objects on the screen.
  If you use hardware FPU support however (see optimize 2), floats are much
  faster than Quicks.
  
  Quick is the default type in Syntax 0 variable declaration strictness level.

2.5.5 Float (.f)
  
  The type Float is a signed 32 bit floating point. One bit for the sign, 23 bit
  for the mantissa and 8 bit for the exponent.
  
  Floats are calculated either by software emulation (slow) or by a
  hardware FPU. Which implementation is used will be defined during compile time
  using the optimize 2 directive.
  
  Note: If you compile your program with "optimize 2", it will require
        an FPU to run.  

  Note: If you switch between software/hardware floats within a program,
        the float variables are not compatible, since the softfloat emulation
        uses a different format to store the value. You need to pass their
        value through a string or write a converter routine.  

2.5.6 Double Float (.d)

  The type Double Float is a signed 64 bit floating point. One bit for the sign,
  52 bit for the mantissa and 11 bit for the exponent.

  This type has a very high accuracy and value range. It is only available if 
  hardware FPU support is switched on using the "optimize 2" directive.
  There is no software emulation build in.

2.5.7 String (.s or $)

  The type String is a variable sized, 0-terminated byte array.
  A string can contain any byte value, including the 0-byte. The acutal
  length and the length of the buffer is seperately stored.
  
  Usually, the length of the buffer is increased/decreased automatically wihtout
  the programmers notice. But in certain situations, it is handy to set it
  explicitly via:
  +-----------------------------------------------------------------------------
  | 
  | Maxlen string.s = n      ; the the strings buffer to n bytes.
  | 
  +-----------------------------------------------------------------------------

  The length of a string is practially only limited by the global temporary
  string buffer that is used during string operations to compose a result
  string. The size of this buffer is set in the compiler settings of the IDE.
  
  The extention .s of a string can also be written in the traditional BASIC
  style using a $. In that case, the $ become also part of the variable name and
  must always be written.

2.5.8 Pointer (*)
  
  See 2.7 Pointers for more information.
  

Contents | Index | < Browse | Browse >