We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
4-Byte Floats (Read 627 times)
4-Byte Floats
Apr 7th, 2010, 8:49pm
 
Hello

I'm trying to convert 4-byte BIG-endian floats into Processing float.  For example, I might have these four bytes: 35 3A CC CF; which should convert to 6.95 e-7.  I'm able to convert 1 byte, such as 1A --> 26, but I'm having trouble with 4-byte floats.  Any Ideas?

How is the Processing float constructed?
Re: 4-Byte Floats
Reply #1 - Apr 8th, 2010, 4:54am
 
Endian-ness doens't affect the order of bits normally, just of the bytes, so the only thing you'd have to do is swap the byte chunks around. And it seems that the endian-ness isn't a problem with your values:

Code:
float f=Float.intBitsToFloat(0x353ACCCF);
println(f);
Re: 4-Byte Floats
Reply #2 - Apr 8th, 2010, 11:00am
 
problem solved!  thanks very much!
Page Index Toggle Pages: 1