bit pattern stored as a float?

BlitzMax Forums/BlitzMax Beginners Area/bit pattern stored as a float?

JBR(Posted 2010) [#1]
Hi,

I would like to store an integer value as a float in an array and then get it back from the array to an int.

I don't want the integer converted to a float, what I want is the bit pattern to be kept.

Is this possible?
Jim


BladeRunner(Posted 2010) [#2]
Simple: no. A conversion to float means it will be saved with lesser precision but higher range. There will always be numbers that change.


Yan(Posted 2010) [#3]
Strict

Local myVertArray#[6]
Local myVertColour = $FFAABACA

Print Hex$(myVertColour)

(Int Ptr(Float Ptr(myVertArray#)))[3] = myVertColour

Print myVertArray#[3]

myVertColour = (Int Ptr(Float Ptr(myVertArray#)))[3]

Print Hex$(myVertColour)



Czar Flavius(Posted 2010) [#4]
If you describe in more detail why you want to do this, we might be able to suggest an alternate method that better suits your needs.


JBR(Posted 2010) [#5]
Hi, thanks guys, Yan has nailed it.

Basically I am keeping things in a Float array mainly and one value in an Intger array. For neatness I wanted the lot to be stored in the float array. Simple as that!

Thanks
Jim