Just wondering.
Can a double be 32 bits?
Collapse
This topic is closed.
X
X
-
spasmousTags: None -
Ian Collins
Re: Can a double be 32 bits?
spasmous wrote:About what?Just wondering.
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.
-
spasmous
Re: Can a double be 32 bits?
On Apr 18, 3:19 pm, Ian Collins <ian-n...@hotmail.co mwrote:I can't locate anywhere official-looking that it says this. Does the Cspasmous 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.
>
standard mandate some minimum number of bits?
Comment
-
Bartc
Re: Can a double be 32 bits?
"spasmous" <spasmous@gmail .comwrote in message
news:15d416be-0f70-42da-91d2-1c529b561455@p2 5g2000pri.googl egroups.com...
On Apr 18, 3:19 pm, Ian Collins <ian-n...@hotmail.co mwrote:>>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.Aparently the minimum is 10 decimal digits. With the exponent added, 32 bits>I can't locate anywhere official-looking that it says this. Does the C
>standard mandate some minimum number of bits?
is not enough.
In practice a double will likely be 64 bits. But with C nothing is ever
certain.
--
Bart
Comment
-
Walter Roberson
Re: Can a double be 32 bits?
In article <15d416be-0f70-42da-91d2-1c529b561455@p2 5g2000pri.googl egroups.com>,
spasmous <spasmous@gmail .comwrote:>On Apr 18, 3:19=A0pm, Ian Collins <ian-n...@hotmail.co mwrote:>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.No, but it mandates minimum value ranges and minimum precisions.>I can't locate anywhere official-looking that it says this. Does the C
>standard mandate some minimum number of bits?
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
Comment
-
Dann Corbit
Re: Can a double be 32 bits?
"Bartc" <bc@freeuk.comw rote in message
news:Jt9Oj.1091 8$yD2.8861@text .news.virginmed ia.com...Even without the exponent, it takes ~33.22 bits to maintain correctly 10>
"spasmous" <spasmous@gmail .comwrote in message
news:15d416be-0f70-42da-91d2-1c529b561455@p2 5g2000pri.googl egroups.com...
On Apr 18, 3:19 pm, Ian Collins <ian-n...@hotmail.co mwrote:>>>>>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.
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.
A double will have at least 10 decimal digits of precision and an exponentIn practice a double will likely be 64 bits. But with C nothing is ever
certain.
of at least +/- 37. So at least that much is certain.
;-)
** Posted from http://www.teranews.com **
Comment
-
Richard
Re: Can a double be 32 bits?
Ian Collins <ian-news@hotmail.co mwrites:
The "Subject"?spasmous wrote:>>Just wondering.
About what?
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.Comment
-
James Harris
Re: Can a double be 32 bits?
On 19 Apr, 00:55, "Dann Corbit" <dcor...@connx. comwrote:...."Bartc" <b...@freeuk.co mwrote in message
5.2 bits??? I think the exponent is stored in binary so would need to>>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.
be larger. Assuming the exponent can be in the range
from: 10 ** -37
to : 10 ** 37
since
log2(10 ** -39) = -129.55519570060 713
log2(10 ** -38) = -126.23326760571 979
log2(10 ** -37) = -122.91133951083 242
log2(10 ** 37) = 122.91133951083 242
log2(10 ** 38) = 126.23326760571 976
log2(10 ** 39) = 129.55519570060 713
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.
Comment
-
user923005
Re: Can a double be 32 bits?
On Apr 21, 8:29 am, James Harris <james.harri... @googlemail.com >
wrote:If you read carefully, you will see that I reserved an extra bit forOn 19 Apr, 00:55, "Dann Corbit" <dcor...@connx. comwrote:
>>"Bartc" <b...@freeuk.co mwrote 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.55519570060 713
log2(10 ** -38) = -126.23326760571 979
log2(10 ** -37) = -122.91133951083 242
>
log2(10 ** 37) = 122.91133951083 242
log2(10 ** 38) = 126.23326760571 976
log2(10 ** 39) = 129.55519570060 713
>
the exponent seems to need a value in the range -123 up to +123 (247
values) and therefore would need 8 bits.
the sign.
pow(2,
5.2094533656289 497818578041776 131754997614249 696721880487516 636221416853906 4)
is ~37
Hence, 5.2 bits.
The C standard only asks for +/-37 and so trying to obtain 38 is notInterestingly 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.
salient.
It would be possible to physically store floating numbers using
artithmetic compression, so fractional bits are possible.
Comment
-
James Harris
Re: Can a double be 32 bits?
On 21 Apr, 21:04, user923005 <dcor...@connx. comwrote:
....
Sure (though an exponent is normally stored biased and non-negative so>>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.55519570060 713
log2(10 ** -38) = -126.23326760571 979
log2(10 ** -37) = -122.91133951083 242>log2(10 ** 37) = 122.91133951083 242
log2(10 ** 38) = 126.23326760571 976
log2(10 ** 39) = 129.55519570060 713>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.
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.
....
My comment was the other way round, i.e. given that an 8-bit exponent>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.
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.Comment
-
Dik T. Winter
Re: Can a double be 32 bits?
In article <51a0d286-a2cb-4357-a01f-7844793d9ea0@c1 9g2000prf.googl egroups.comJame s Harris <james.harris.1 @googlemail.com writes:
........log2(10 ** -38) = -126.23326760571 979
log2(10 ** -37) = -122.91133951083 242
>
log2(10 ** 37) = 122.91133951083 242
log2(10 ** 38) = 126.23326760571 976It all depends on how hardware implements floating point. For instancethe 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.
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/
Comment
-
user923005
Re: Can a double be 32 bits?
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.55519570060 713
log2(10 ** -38) = -126.23326760571 979
log2(10 ** -37) = -122.91133951083 242>log2(10 ** 37) = 122.91133951083 242
log2(10 ** 38) = 126.23326760571 976
log2(10 ** 39) = 129.55519570060 713>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.
Comment
Comment