Home » Community » Newbie corner » Writing Float big-endian on Windows
Re: Writing Float big-endian on Windows [message #31356 is a reply to message #31355] |
Fri, 25 February 2011 07:19   |
|
RedDevil wrote on Fri, 25 February 2011 02:04 | I am just starting to use U++ and find the experience very satisfying so far. I need to be able to read and write floats (SP) is big-endian format. I could not fine the equivalent to something like 'Put32be'. Any help would be appreciated - thanks.
|
Hi RedDevil
You can use the Put32be for this as well. All you have to do is to (carefully) cast the number into integer. Something like this should work:
stream.Put32be(*((int*)&f)); //where f is your float
Note that you must cast pointers, not the float directly, otherwise the value would be converted (and the bits would change). Similar trick is possible when reading as well, just the other way around.
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Sun Apr 27 13:09:35 CEST 2025
Total time taken to generate the page: 0.00680 seconds
|