YesNoOk
avatar

Expressions & Data Types (CNS) (Read 1170 times)

Started by Just No Point, October 06, 2015, 10:46:52 pm
Share this topic:
Expressions & Data Types (CNS)
#1  October 06, 2015, 10:46:52 pm
  • ******
    • www.justnopoint.com/

  • Online
Expressions

MUGEN supports arithmetic expressions in most triggers and state controllers. This allows much more flexible and customizable behavior than would be possible using only fixed values. This section gives a description of expression concepts and syntax.



Data Types

MUGEN uses three data types: 32-bit integers, 32-bit floats, and a special null value, "bottom". Integers represent whole numbers between -2^31 and 2^31-1, or about -2 billion to 2 billion. Floats are single-precision floating-point numbers. That is, they are numbers with a "decimal part" and about 7 significant figures of precision. Floats can represent small fractions or very large numbers.

When you write numbers in an expression, MUGEN deduces the data type from the presence of a decimal point. Thus "7" is always an int, for example. If you wanted 7 as a float, then you would write "7.0".

"bottom" is a special data type that zeros out any expression that it appears in (with a few very limited exceptions). Its presence signifies some kind of error condition. You should try to code in such a way that bottom is never produced. For details, you can see the dedicated section on bottom.

The behavior of arithmetic expressions depends heavily on the underlying data types used to represent numbers. Also, state controllers may expect their input to be given as a certain type, and will give errors if the wrong type is supplied.

"Type promotion" occurs when values of different data types need to be combined in some way (e.g., by addition). Generally this means that an integer will be changed to a float, with possible loss of precision in the process. In the sections below we will note any relevant type promotion scenarios.