Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: TIme and Idle
Next Topic: Some code to add an icon in statusbar
Goto Forum:
  


Current Time: Sun Apr 27 13:09:35 CEST 2025

Total time taken to generate the page: 0.00680 seconds