473,386 Members | 1,720 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,386 software developers and data experts.

Can a double be 32 bits?

Just wondering.
Jun 27 '08 #1
11 2320
spasmous wrote:
Just wondering.
About what?

Ah, I see, please put your question in the body of your message.

Can a double be 32 bits?

No, 32 bits is too small.

--
Ian Collins.
Jun 27 '08 #2
On Apr 18, 3:19*pm, Ian Collins <ian-n...@hotmail.comwrote:
spasmous wrote:
Just wondering.

About what?

Ah, I see, please put your question in the body of your message.

Can a double be 32 bits?

No, 32 bits is too small.
I can't locate anywhere official-looking that it says this. Does the C
standard mandate some minimum number of bits?
Jun 27 '08 #3

"spasmous" <sp******@gmail.comwrote in message
news:15**********************************@p25g2000 pri.googlegroups.com...
On Apr 18, 3:19 pm, Ian Collins <ian-n...@hotmail.comwrote:
>spasmous wrote:
Just wondering.

About what?
>Ah, I see, please put your question in the body of your message.
>Can a double be 32 bits?
>No, 32 bits is too small.
>I can't locate anywhere official-looking that it says this. Does the C
standard mandate some minimum number of bits?
Aparently the minimum is 10 decimal digits. With the exponent added, 32 bits
is not enough.

In practice a double will likely be 64 bits. But with C nothing is ever
certain.

--
Bart
Jun 27 '08 #4
In article <15**********************************@p25g2000pri. googlegroups.com>,
spasmous <sp******@gmail.comwrote:
>On Apr 18, 3:19=A0pm, Ian Collins <ian-n...@hotmail.comwrote:
>spasmous wrote:
Just wondering.
>About what?
>Ah, I see, please put your question in the body of your message.
>Can a double be 32 bits?
>No, 32 bits is too small.
>I can't locate anywhere official-looking that it says this. Does the C
standard mandate some minimum number of bits?
No, but it mandates minimum value ranges and minimum precisions.
About a week ago, there was a calculation posted showing that
approximately 40.4 value bits would be required to meet the specification;
with 1 "hidden bit", it is perhaps doable in 40 bits. But not 32.

--
"Man's life is but a jest,
A dream, a shadow, bubble, air, a vapor at the best."
-- George Walter Thornbury
Jun 27 '08 #5
"Bartc" <bc@freeuk.comwrote in message
news:Jt******************@text.news.virginmedia.co m...
>
"spasmous" <sp******@gmail.comwrote in message
news:15**********************************@p25g2000 pri.googlegroups.com...
On Apr 18, 3:19 pm, Ian Collins <ian-n...@hotmail.comwrote:
>>spasmous wrote:
Just wondering.

About what?
>>Ah, I see, please put your question in the body of your message.
>>Can a double be 32 bits?
>>No, 32 bits is too small.
>>I can't locate anywhere official-looking that it says this. Does the C
standard mandate some minimum number of bits?

Aparently the minimum is 10 decimal digits. With the exponent added, 32
bits is not enough.
Even without the exponent, it takes ~33.22 bits to maintain correctly 10
decimal digits, and we also need to be able to store an exponent of +/-37,
requiring ~5.2 bits so 39 bits +2 bits for signs (one implicit) gives us 40
bits as a mathematical bare minimum that we could expect to be used for data
type double in the C language.
In practice a double will likely be 64 bits. But with C nothing is ever
certain.
A double will have at least 10 decimal digits of precision and an exponent
of at least +/- 37. So at least that much is certain.
;-)
** Posted from http://www.teranews.com **
Jun 27 '08 #6
Ian Collins <ia******@hotmail.comwrites:
spasmous wrote:
>Just wondering.

About what?
The "Subject"?

Tricky eh?
>
Ah, I see, please put your question in the body of your message.

Can a double be 32 bits?

No, 32 bits is too small.
Jun 27 '08 #7
On 19 Apr, 00:55, "Dann Corbit" <dcor...@connx.comwrote:
"Bartc" <b...@freeuk.comwrote in message
....
>No, 32 bits is too small.
>I can't locate anywhere official-looking that it says this. Does the C
standard mandate some minimum number of bits?
Aparently the minimum is 10 decimal digits. With the exponent added, 32
bits is not enough.

Even without the exponent, it takes ~33.22 bits to maintain correctly 10
decimal digits, and we also need to be able to store an exponent of +/-37,
requiring ~5.2 bits so 39 bits +2 bits for signs (one implicit) gives us 40
bits as a mathematical bare minimum that we could expect to be used for data
type double in the C language.
5.2 bits??? I think the exponent is stored in binary so would need to
be larger. Assuming the exponent can be in the range

from: 10 ** -37
to : 10 ** 37

since

log2(10 ** -39) = -129.55519570060713
log2(10 ** -38) = -126.23326760571979
log2(10 ** -37) = -122.91133951083242

log2(10 ** 37) = 122.91133951083242
log2(10 ** 38) = 126.23326760571976
log2(10 ** 39) = 129.55519570060713

the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits. Interestingly it looks like
the range for 10 ** +/- 38 could just be accommodated in eight bits as
it needs -127 up to 127 (255 values) leaving one value to indicate
others such as NaNs.

Jun 27 '08 #8
On Apr 21, 8:29*am, James Harris <james.harri...@googlemail.com>
wrote:
On 19 Apr, 00:55, "Dann Corbit" <dcor...@connx.comwrote:
"Bartc" <b...@freeuk.comwrote in message

...
>>No, 32 bits is too small.
>>I can't locate anywhere official-looking that it says this. Does the C
>>standard mandate some minimum number of bits?
Aparently the minimum is 10 decimal digits. With the exponent added, 32
bits is not enough.
Even without the exponent, it takes ~33.22 bits to maintain correctly 10
decimal digits, and we also need to be able to store an exponent of +/-37,
requiring ~5.2 bits so 39 bits +2 bits for signs (one implicit) gives us40
bits as a mathematical bare minimum that we could expect to be used for data
type double in the C language.

5.2 bits??? I think the exponent is stored in binary so would need to
be larger. Assuming the exponent can be in the range

from: 10 ** -37
to *: 10 ** 37

since

log2(10 ** -39) = -129.55519570060713
log2(10 ** -38) = -126.23326760571979
log2(10 ** -37) = -122.91133951083242

log2(10 ** 37) = 122.91133951083242
log2(10 ** 38) = 126.23326760571976
log2(10 ** 39) = 129.55519570060713

the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits.
If you read carefully, you will see that I reserved an extra bit for
the sign.

pow(2,
5.209453365628949781857804177613175499761424969672 18804875166362214168539064)
is ~37
Hence, 5.2 bits.
Interestingly it looks like
the range for 10 ** +/- 38 could just be accommodated in eight bits as
it needs -127 up to 127 (255 values) leaving one value to indicate
others such as NaNs.
The C standard only asks for +/-37 and so trying to obtain 38 is not
salient.

It would be possible to physically store floating numbers using
artithmetic compression, so fractional bits are possible.
Jun 27 '08 #9
On 21 Apr, 21:04, user923005 <dcor...@connx.comwrote:

....
>No, 32 bits is too small.
>I can't locate anywhere official-looking that it says this. Does the C
>standard mandate some minimum number of bits?
Aparently the minimum is 10 decimal digits. With the exponent added, 32
bits is not enough.
Even without the exponent, it takes ~33.22 bits to maintain correctly 10
decimal digits, and we also need to be able to store an exponent of +/-37,
requiring ~5.2 bits so 39 bits +2 bits for signs (one implicit) gives us 40
bits as a mathematical bare minimum that we could expect to be used for data
type double in the C language.
5.2 bits??? I think the exponent is stored in binary so would need to
be larger. Assuming the exponent can be in the range
from: 10 ** -37
to : 10 ** 37
since
log2(10 ** -39) = -129.55519570060713
log2(10 ** -38) = -126.23326760571979
log2(10 ** -37) = -122.91133951083242
log2(10 ** 37) = 122.91133951083242
log2(10 ** 38) = 126.23326760571976
log2(10 ** 39) = 129.55519570060713
the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits.

If you read carefully, you will see that I reserved an extra bit for
the sign.
Sure (though an exponent is normally stored biased and non-negative so
doesn't have a sign bit per se) but neither 5, 5.2, nor (with an extra
'sign' bit) 6 or 6.2 bits seem to be enough. I was saying that (if the
mantissa is a binary number as normal) the exponent will need to range
from -123 to +123, not -37 up to +37. (2 ** 123 is a little over 10 **
37 to cover the exponent of +/- 37 that you mention is needed for C) I
think you therefore need 8 bits for the exponent for the C requirement
of 10 ** +/- 37.

You could possibly make the mantissa a decimal number and then use
your 5.2 or 6.2 bits figure but a decimal number would not be stored
as efficiently as a binary one and would therefore store less in a
given space.

....
Interestingly it looks like
the range for 10 ** +/- 38 could just be accommodated in eight bits as
it needs -127 up to 127 (255 values) leaving one value to indicate
others such as NaNs.

The C standard only asks for +/-37 and so trying to obtain 38 is not
salient.
My comment was the other way round, i.e. given that an 8-bit exponent
is needed (as it is to hold the 247 values from -123 up to 123) it can
hold higher numbers using some of the 9 remaining values (256 - 247 =
9). At least one of the values needs to be reserved for NaNs etc but
that still seems to allow 10 ** +/- 38. It would depend on the
representation.
It would be possible to physically store floating numbers using
artithmetic compression, so fractional bits are possible.
Jun 27 '08 #10
In article <51**********************************@c19g2000prf. googlegroups.comJames Harris <ja************@googlemail.comwrites:
....
log2(10 ** -38) = -126.23326760571979
log2(10 ** -37) = -122.91133951083242

log2(10 ** 37) = 122.91133951083242
log2(10 ** 38) = 126.23326760571976
....
the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits. Interestingly it looks like
the range for 10 ** +/- 38 could just be accommodated in eight bits as
it needs -127 up to 127 (255 values) leaving one value to indicate
others such as NaNs.
It all depends on how hardware implements floating point. For instance
on the PDP and the VAX (where C did originate), the maximum exponent
was 126 and the minimum exponent was -128 (the bias was 129). When
you read the literature you will find a bias of 128, but on those machines
the binary point was in *front* of the first bit of the mantissa, in IEEE
it is just behind that first bit. When you move the point one place, you
shift the true exponent by one. Floating point representation is a bit
tricky.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jun 27 '08 #11
On Apr 21, 5:56*pm, James Harris <james.harri...@googlemail.com>
wrote:
On 21 Apr, 21:04, user923005 <dcor...@connx.comwrote:

...


>>No, 32 bits is too small.
>>I can't locate anywhere official-looking that it says this. Does the C
>>standard mandate some minimum number of bits?
Aparently the minimum is 10 decimal digits. With the exponent added, 32
bits is not enough.
Even without the exponent, it takes ~33.22 bits to maintain correctly 10
decimal digits, and we also need to be able to store an exponent of +/-37,
requiring ~5.2 bits so 39 bits +2 bits for signs (one implicit) gives us 40
bits as a mathematical bare minimum that we could expect to be used for data
type double in the C language.
5.2 bits??? I think the exponent is stored in binary so would need to
be larger. Assuming the exponent can be in the range
from: 10 ** -37
to *: 10 ** 37
since
log2(10 ** -39) = -129.55519570060713
log2(10 ** -38) = -126.23326760571979
log2(10 ** -37) = -122.91133951083242
log2(10 ** 37) = 122.91133951083242
log2(10 ** 38) = 126.23326760571976
log2(10 ** 39) = 129.55519570060713
the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits.
If you read carefully, you will see that I reserved an extra bit for
the sign.

Sure (though an exponent is normally stored biased and non-negative so
doesn't have a sign bit per se) but neither 5, 5.2, nor (with an extra
'sign' bit) 6 or 6.2 bits seem to be enough. I was saying that (if the
mantissa is a binary number as normal) the exponent will need to range
from -123 to +123, not -37 up to +37. (2 ** 123 is a little over 10 **
37 to cover the exponent of +/- 37 that you mention is needed for C) I
think you therefore need 8 bits for the exponent for the C requirement
of 10 ** +/- 37.

You could possibly make the mantissa a decimal number and then use
your 5.2 or 6.2 bits figure but a decimal number would not be stored
as efficiently as a binary one and would therefore store less in a
given space.

...
Interestingly it looks like
the range for 10 ** +/- 38 could just be accommodated in eight bits as
it needs -127 up to 127 (255 values) leaving one value to indicate
others such as NaNs.
The C standard only asks for +/-37 and so trying to obtain 38 is not
salient.

My comment was the other way round, i.e. given that an 8-bit exponent
is needed (as it is to hold the 247 values from -123 up to 123) it can
hold higher numbers using some of the 9 remaining values (256 - 247 =
9). At least one of the values needs to be reserved for NaNs etc but
that still seems to allow 10 ** +/- 38. It would depend on the
representation.
It would be possible to physically store floating numbers using
artithmetic compression, so fractional bits are possible.
http://en.wikipedia.org/wiki/Arithmetic_coding
Jun 27 '08 #12

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

Similar topics

20
by: Anonymous | last post by:
Is there a non-brute force method of doing this? transform() looked likely but had no predefined function object. std::vector<double> src; std::vector<int> dest; ...
22
by: Fred Ma | last post by:
I'm using the expression "int a = ceil( SomeDouble )". The man page says that ceil returns the smallest integer that is not less than SomeDouble, represented as a double. However, my...
67
by: lcw1964 | last post by:
This may be in the category of bush-league rudimentary, but I am quite perplexed on this and diligent Googling has not provided me with a clear straight answer--perhaps I don't know how to ask the...
2
by: tkirankumar | last post by:
Hi all, uname -a SunOS cbmrsd1a1 5.10 Generic_118833-17 sun4us sparc FJSV,GPUZC-M g++ -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.10/3.3.2/specs Configured with:...
11
by: Steven Woody | last post by:
long i = nnn; long j; double d; d = i; j = ( long )d; in this case, i == j ? thanks.
29
by: Virtual_X | last post by:
As in IEEE754 double consist of sign bit 11 bits for exponent 52 bits for fraction i write this code to print double parts as it explained in ieee754 i want to know if the code contain any...
18
by: eman.abu.samra | last post by:
Hi all, i have encountered the strangest behavior. Check out this simple program: #include <stdio.h> int main() { double time = 1;
0
by: Charles Coldwell | last post by:
James Kanze <james.kanze@gmail.comwrites: True, with some additional considerations. The commonly used IEEE 754 floating point formats are single precision: 32 bits including 1 sign bit, 23...
2
by: James Harris | last post by:
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...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.