Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is this possible? Brute force conversion
#5
It works with arrays, too:

dim f as single = 12.3423
dim array(0) as integer = { *cast(integer ptr, @f) }
print *cast(single ptr, @array(0)) ' prints 12.3423

The reinterpretation of the raw data is what you want. It seems a direct cast from single to integer converts the value - that is, it truncates the decimal; C and C++ do the same thing. Casting the pointer type - the address of the data - from float pointer to integer pointer does not convert the value, it just reinterprets the floating point raw data as something else - the value does not change.
stylin:
Reply


Messages In This Thread
Is this possible? Brute force conversion - by stylin - 01-21-2007, 01:10 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)