BlitzMax

BlitzMax

  • Downloads
  • Docs
  • API
  • Resources
  • About

›Language

Setup

  • Getting Started
  • Win32
  • Linux
  • macOS
  • Android
  • iOS
  • Raspberry Pi
  • NX (Switch Homebrew)
  • Custom Settings

Tutorials

  • Beginners Guide
  • OOP Tutorial
  • Network Programming
  • TCP Socket Programming

Language

  • Arrays
  • Basic Compatibility
  • Collections
  • Comments
  • Conditional Compiling
  • Constants
  • Data Types
  • Debugging
  • Enums
  • Exceptions
  • Expressions
  • Functions
  • Identifiers
  • Literals
  • Modules
  • Objects
  • Program Flow
  • Slices
  • Strings
  • User Defined Types
  • Variables
  • Advanced Topics

    • Interfacing With C
    • Memory Management
    • Pointers
    • Custom Pre/Post Compilation Scripts
    • Creating DLLs

Tools

  • MaxIDE
  • BlitzMax Make (bmk)
  • BlitzMax Compiler (bcc)
Edit

Data Types

All constants, variables, functions and expressions have an associated type. BlitzMax supports the following types:

DescriptionSyntaxMinimum valueMaximum value
8 bit unsigned integerByte0255
16 bit unsigned integerShort065535
32 bit signed integerInt-2^31+2^31-1
32 bit unsigned integerUInt0+2^32-1
64 bit signed integerLong-2^63+2^63-1
64 bit unsigned integerULong0+2^64-1
32 bit floating pointFloat(+/-)10^-38(+/-)10^38
64 bit floating pointDouble(+/-)10^-308(+/-)10^308
16 bit unicode stringString
Unsigned integer (32 bit arch)Size_T0+2^32-1
Unsigned integer (64 bit arch)Size_T0+2^64-1
64 bit SIMD floatFloat64
128 bit SIMD integerInt128
128 bit SIMD floatFloat128
128 bit SIMD doubleDouble128
ObjectTypename
ArrayElementType [ ]
FunctionReturnType ( Parameters )
PointerValueType Ptr
VariableVariableType Var

Integers are used to store simple numeric data without any fractional part. Unsigned integers can only store positive values, while signed integers can store both positive and negative values.

Floating point values are used to store numeric data which may have a fractional part.

SIMD values are available on x64 architectures and can be used for performing numeric calculations more efficiently.

Strings are used to store sequences of characters: letters, punctuation, digits and so on. Use strings for storing non-numeric data such as names.

Arrays are used to store sequences of variables. A variable within an array is accessed by 'indexing' the array with an integer offset. Please refer to the arrays sections for more information on arrays.

Objects are instances of user-defined types. Please refer to the user-defined types section.

Type Conversions

The following type conversions are performed automatically by BlitzMax when necessary - for example, when assigning an expression to a variable, or when passing an expression to a function:

Source TypeTarget Type
IntegerFloating point, String
Floating pointString

You can also convert types explicitly using a cast operation. This takes the form of a type specifier followed by an expression in brackets.

Explicit casting allows you to perform the following extra conversions:

Source TypeTarget Type
StringInteger, Floating point

For example:

Local n:Int=10
Local t:String="20"
Print Int( t )
Print String( n )

Type Balancing

When performing arithmetic operations such as addition or multiplication, it is possible to provide mismatched argument types. For example, the addition operator may be used to add an integer value to a floating point value. But what type should the result be?

BlitzMax decides the result type by balancing the argument types. Both arguments are then converted to the result type before the operator is applied.

The rules governing type balancing are:

If either argument is Double, then result is Double

else if either argument is Float, then result is Float

else if either argument is ULong, then result is ULong

else if either argument is Size_T, then result is Size_T

else if either argument is WParam, then result is WParam

else if one argument is Long and the other UInt, then result is ULong

else if either argument is LParam, then result is LParam

else if either argument is Long, then result is Long

else if either argument is UInt, then result is UInt

else result is Int

← ConstantsDebugging →
  • Type Conversions
  • Type Balancing
BlitzMax
Docs
Getting StartedDownloadsAbout
Community
ResourcesSyntaxBomb Forums
More
GitHubStarChat on Discord
Copyright © 2023 Bruce A Henderson