473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Floats on 64 bit machines

Just a quick question -- are floats on 64 bit machines (Windows/Linux)
still going to be 4 bytes, or will they be 8 bytes? Is there any
guarentee that a float is four bytes?

John
Jun 27 '08 #1
3 8445
ul**@rogers.com wrote:
Just a quick question -- are floats on 64 bit machines (Windows/Linux)
still going to be 4 bytes, or will they be 8 bytes?
I've only seen 4-byte floats so far. The Standard does not require the
upper limit, though, only the lower limit.
Is there any
guarentee that a float is four bytes?
No.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
On 2008-06-12 16:20:35 +0200, ul**@rogers.com said:
Just a quick question -- are floats on 64 bit machines (Windows/Linux)
still going to be 4 bytes, or will they be 8 bytes? Is there any
guarentee that a float is four bytes?
The C++ Standard doesn't say much about sizes of floats and doubles.
Many systems implement IEEE-754, which provides a 32-bit single format
and a 64-bit double format. Those are typically mapped to float and
double, respectively.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Jun 27 '08 #3
On Jun 12, 4:20 pm, u...@rogers.com wrote:
Just a quick question -- are floats on 64 bit machines
(Windows/Linux) still going to be 4 bytes, or will they be 8
bytes? Is there any guarentee that a float is four bytes?
No, there never has been. There's probably a minimum size (in
bits), because the standard does make some guarantees concerning
range and precision, but it's difficult to establish, since the
standard allows different bases. And there's definitely no
maximum size.

If you limit yourself to machines with IEEE floating point, then
you can pretty much count on a float being 32 bits---for most
machines, this will mean a size of 4 (but from what I've heard,
on some DSP, it will be a size of 1).

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orient�e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: ben | last post by:
i'm learning about the floating point format that's used on my computer (apple mac so powerpc) i've written a function to print out the bits in a float to see how floats are represented and i...
44
by: Kosio | last post by:
-Hello, I'm looking for a way to deconstruct a (32 bit) float value to four (8 bit) char values. I then need a way to take those four (8 bit) char values and construct a (32 bit) float value. ...
24
by: hammer1234 | last post by:
Hi I am wondering if there is a way of using the underlying bit representations of floats. I am interested in creating a violation in MISRA C:2004 of rule "The underlying bit representations...
23
by: Arnaud Delobelle | last post by:
Hi all, I want to know the precision (number of significant digits) of a float in a platform-independent manner. I have scoured through the docs but I can't find anything about it! At the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.