Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Int and Float

3 replies · 1,980 views · Started 21 November 2007

I don't really understand how int and float work completely.
From what I understand, int, short for integer, should store a numerical value which is truncated to an integer, so no decimal places are held. And float simmilarily stores a numerical value, but also stores decimal places.

But this can't be true, because in std.zh it clearly says 'const int PI = 3.14'.
I'm assuming const is constant, but 3.14 is still not an integer.

And I've also saved divisions of numbers for FFC speeds which surely should have at least some decimal places as int values, which seem to work fine also.

Could someone explain this to me please?

There is no difference between ints and floats. Ints are not true integers, nor are floats true floating-point numbers - both are just 4-digit (in decimal) fixed-point numbers, which is the underlying data type of ZASM.

Since these numbers are not true ints nor true floats, ZScript allows you to call them by either name. It doesn't matter which you choose, though it might help highlight your intent in a piece of code to use one over the other.

Any chance of these changing to reflect actual ints and floats in the future. People should know so that scripts don't break in the future.