PDA

View Full Version : Int and Float



Joe123
11-21-2007, 05:55 PM
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?

DarkDragon
11-21-2007, 06:58 PM
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.

Praethus
11-22-2007, 02:00 PM
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.

beefster09
11-23-2007, 01:27 AM
Don't ints just get truncated or something?