By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,018 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,018 IT Pros & Developers. It's quick & easy.

What are the minimum numbers of bits required to represent C stdfloat and double components?

P: n/a
I'm trying to make sense of the standard C data sizes for floating
point numbers. I guess the standards were written to accommodate some
particular floating point engines that were popular at one time but I
can only find references to the number of decimals etc. Basically, if
I wanted to specify C-sized reals in a language that only accepted bit-
widths, e.g.

float(exponent 8, mantissa 24)

I'm looking for what numbers would be needed for the exponent and
mantissa sizes to accurately mirror the C standard minimum widths. Not
sure my log calcs are correct......

AFAIK the sizes for real numbers must be at least

float: range 10^+/-37, precision 6 digits
double: range 10^+/-37, precision 10 digits

I think this means the number of bits used would be

float: 8 bits for exponent, 20 bits for mantissa
double: 8 bits for exponent, 33 bits for mantissa

These are much smaller than (and thus can be represented by) the
IEEE754 standard which has

ieee single precision: 8 bits for exponent, 24 bits for mantissa
ieee double precision: 11 bits for exponent, 53 bits for mantissa

In all cases the mantissa bits include the sign. Are my figures
correct for the number of bits needed for a mimimal C representation,
above? The double of 33 bits, especially, looks wrong.

Does the C standard specify /at least/ 10 digits of precision for
doubles or is it /about/ 10 digits? Or should it be at least /9/
digits and the mantissa 32 bits (making 40 in all with the exponent)?

--
TIA,
James
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
James Harris wrote:
I'm trying to make sense of the standard C data sizes for floating
point numbers. I guess the standards were written to accommodate some
particular floating point engines that were popular at one time but I
can only find references to the number of decimals etc. Basically, if
I wanted to specify C-sized reals in a language that only accepted bit-
widths, e.g.

float(exponent 8, mantissa 24)

I'm looking for what numbers would be needed for the exponent and
mantissa sizes to accurately mirror the C standard minimum widths. Not
sure my log calcs are correct......
See the earlier thread "Can a double be 32 bits" and section 5.2.4.2.2
of the standard for more detail.

--
Ian Collins.
Jun 27 '08 #2

P: n/a
On 19 Apr, 03:12, Ian Collins <ian-n...@hotmail.comwrote:
James Harris wrote:
I'm trying to make sense of the standard C data sizes for floating
point numbers. I guess the standards were written to accommodate some
particular floating point engines that were popular at one time but I
can only find references to the number of decimals etc. Basically, if
I wanted to specify C-sized reals in a language that only accepted bit-
widths, e.g.
float(exponent 8, mantissa 24)
I'm looking for what numbers would be needed for the exponent and
mantissa sizes to accurately mirror the C standard minimum widths. Not
sure my log calcs are correct......

See the earlier thread "Can a double be 32 bits" and section 5.2.4.2.2
of the standard for more detail.
Thanks but I don't see how they help at all. The standard gives
figures in decimal (as in my original post). And the 32-bit thread
says doubles need 10 digits where the standard seems to say 15.

Was there something specific you were referring to in those
references? As mentioned the query is for the minimum-width /binary/
fields, i.e., I'm looking for the minimum numbers of bits for the
exponent and mantissa of C-standard floats and doubles?

I know the radix may affect this but thought not to add that
complication - at least not yet.
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.