[HLF]Southclaw
Unregistered
So, I was wondering what are floating point values? What defines how many decimals there are in a cell?
How many bits are there?
I also want to know how would I save one to a file if the bit size is different.
Thanks
Posts: 15,941
Threads: 0
Joined: Jun 2008
the best way to save floats is actually as ints:
pawn Код:
format(str, sizeof (str), "%d", floatnumber);
Then to read do:
pawn Код:
sscanf(in, "i", floatnumber);
If "floatnumber" is declared as a float this code will actually work by writing and reading the exact underlying bit pattern of the float, which is by far the best way to do it without loosing accuracy. For more information see IEEE 754.
[HLF]Southclaw
Unregistered
Ah I get it now, I thought they were more bits or something (to hold data for the exponent) But now I see it's done more cleverly. That also explains to me why when floats are printed with %d it just shows some massive integer.
Thanks!