11 2349
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.
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?
"spasmous" <sp******@gmail .comwrote in message
news:15******** *************** ***********@p25 g2000pri.google groups.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.
In practice a double will likely be 64 bits. But with C nothing is ever
certain.
--
Bart
In article <15************ *************** *******@p25g200 0pri.googlegrou ps.com>,
spasmous <sp******@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.
>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
"Bartc" <bc@freeuk.comw rote in message
news:Jt******** **********@text .news.virginmed ia.com...
>
"spasmous" <sp******@gmail .comwrote in message
news:15******** *************** ***********@p25 g2000pri.google groups.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.
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 **
Ian Collins <ia******@hotma il.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.
On 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 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. 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 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.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.
If you read carefully, you will see that I reserved an extra bit for
the sign.
pow(2,
5.2094533656289 497818578041776 131754997614249 696721880487516 636221416853906 4)
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.
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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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;
std::vector<double>::size_type size = src.size();
dest.reserve(size);
for (std::vector<int>::size_type i = 0;
|
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 understanding is that a
double has nonuniform precision throughout its value
range. Will a double always be able to exactly
represent any value of type int? Could someone please
point me to an explanation of how this is ensured,
given that the details of...
|
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 quesion.
I have begun to familiarize myself here with the gcc compiler in a
win32 environment, in the form of MinGW using both Dev C++ and MSYS as
interfaces.
I have recompiled some old math code that uses long double types
throughout and...
|
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: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
|
by: Steven Woody |
last post by:
long i = nnn;
long j;
double d;
d = i;
j = ( long )d;
in this case, i == j ?
thanks.
| |
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 bug , i am still c++ beginner
|
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;
|
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 significand bits
(with an implicit leading 1, for 24 total), and 8 exponent bits
double precision: 64 bits including 1 sign bit, 52 significand bits
|
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 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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |