473,503 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
2 3993
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
13083
by: dleecurt | last post by:
Hello, I have a small problem, I am trying to write a program that will calculate the Fibonacci number series, and I have the code complete with one problem. I used a long in to store the numbers,...
51
4452
by: jacob navia | last post by:
I would like to add at the beginning of the C tutorial I am writing a short blurb about what "types" are. I came up with the following text. Please can you comment? Did I miss something? Is...
86
3842
by: Randy Yates | last post by:
In Harbison and Steele's text (fourth edition, p.111) it is stated, The C language does not specify the range of integers that the integral types will represent, except ot say that type int may...
13
1640
by: puzzlecracker | last post by:
If you run this program, it will give very unexpected results. Can anyone explain the nature of this anamaly? (also what is the function call to execute 'pause'); #include<stdio.h> //void...
17
12745
by: Sri | last post by:
How do you add an n-bit number in C? Regards, Sri
45
2383
by: bobalong | last post by:
Hi I'm have some problem understanding how JS numbers are represented internally. Take this code for an example of weirdness: var biggest = Number.MAX_VALUE; var smaller = Number.MAX_VALUE...
16
2295
by: Martin Jørgensen | last post by:
Hi, Problem: ======== Some of my output functions are beginning to take pretty many arguments... I mean.... We're talking about 10-15 arguments :-) So I thought to myself, perhaps this is...
7
3593
by: junky_fellow | last post by:
Guys, Does the standard allow to an implementation to chose any maximum and minimum value for an object of type int ? For eg. Can an implementation with sizeof(int)=4, chose to have value of...
13
2713
by: Ioannis Vranos | last post by:
Is there any mentioning in the standard of the number of bits of the various built in types, apart from char/signed char/unsigned char types? Or only about the minimum value ranges of them?
0
7091
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...
0
7342
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.