473,666 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

smallest positive double number

Hi, All:

I wonder what is the smallest positive double numbers in C in 32 bit
CPU?

Rick

Nov 14 '05 #1
11 13115
"go***********@ gmail.com" wrote:

I wonder what is the smallest positive double numbers in C in
32 bit CPU?


I have no idea (on your system), but you do. #include <float.h>

--
Some informative links:
news:news.annou nce.newusers
http://www.geocities.com/nnqweb/
http://www.catb.org/~esr/faqs/smart-questions.html
http://www.caliburn.nl/topposting.html
http://www.netmeister.org/news/learn2quote.html
Nov 14 '05 #2
"go***********@ gmail.com" <go***********@ gmail.com> wrote:
I wonder what is the smallest positive double numbers in C in 32 bit
CPU?


That question cannot really be answered. OTOH, there is probably a very
definite and useful answer.
It cannot be answered because having a "32 bit CPU", whichever that
means, does not necessarily mean anything for your integers; means
nearly nothing for the size of your doubles; and means even less for the
representation of those doubles within that size. How a double is
represented is decided by your implementation, not by the CPU. The
implementation probably does take certain aspects of the hardware into
account, but the relevant ones are most likely to be the layout of the
registers of the floating point unit, not the size of the data bus,
fastest or largest integer registers, or whatever aspect of the CPU is
called "32 bit".
It can be answered quite authoritatively for the implementation you are
compiling on at the moment, though: DBL_MIN, from <float.h>, is the
smallest positive normalised double value.

Richard
Nov 14 '05 #3
go***********@g mail.com wrote:
I wonder what is the smallest positive double numbers in C
in 32 bit CPU?


DBL_MIN yields the smallest normalized, finite representable value
of type double. DBL_EPSILON yields the smallest X of type double
such that 1.0 + X != 1.0.

(Source www.dinkumware.com)
Nov 14 '05 #4

On 22/06/2005 09:29, Richard Bos wrote:
"go***********@ gmail.com" <go***********@ gmail.com> wrote:
I wonder what is the smallest positive double numbers in C in 32 bit
CPU?


I wonder... Actually a CPU could have no FPU at all, which happened on 8086,
80286 and 80386 at least, and probably on 68000. Second, it's perfectly
possible that a C compiler don't use the FPU, if there is one, and sometimes
it depends on how you run the compiler. So there are two different
questions: how does your C compiler handle double numbers, and how does your
CPU, if that makes sense. The first was already answered, the second is in
your CPU's manual. If you have not that manual, it's probably on the web:
there are PDF files for Pentium, PowerPC, 68000, Alpha and Sparc, at least.

You question is also tricky for another reason: usually a C compiler handles
float and double numbers, but the Pentium processor can work with extended
precision (that can be set by an asm instruction, maybe no accessible from
C, and certainly not in C standard). If you work with usual 64 bits IEEE754
doubles on a pentium, you may have different results in your computations
depending on which precision is used internally. There is the same kind of
problem on machines with fused-multiply-add (fma). So be aware that you
question is not only related to your compiler, it's also related to your
CPU. Both are off-topic anyway.

Nov 14 '05 #5
Grumble wrote:
go***********@g mail.com wrote:
I wonder what is the smallest positive double numbers in C
in 32 bit CPU?

DBL_MIN yields the smallest normalized, finite representable value
of type double. DBL_EPSILON yields the smallest X of type double
such that 1.0 + X != 1.0.

(Source www.dinkumware.com)

If you have IEEE gradual underflow enabled on your system, subnormal
values DBL_MIN * DBL_EPSILON <= X < DBL_EPSILON are available. This has
nothing to do with "32 bit CPU," nor does "32 bit CPU" have anything to
do with C, except as reflected in <float.h> and <limits.h>.
Nov 14 '05 #6
AC

"Grumble" <de*****@kma.eu .org> wrote in message
news:d9******** **@news-rocq.inria.fr.. .
go***********@g mail.com wrote:
I wonder what is the smallest positive double numbers in C
in 32 bit CPU?


DBL_MIN yields the smallest normalized, finite representable value
of type double. DBL_EPSILON yields the smallest X of type double
such that 1.0 + X != 1.0.

(Source www.dinkumware.com)


The smallest floating point value might not be normal.

What about something like (pseudo code)

x=1;
while(x/FLT_RADIX)
{
x = x/FLT_RADIX;
}
Nov 15 '05 #7
go***********@g mail.com wrote:
I wonder what is the smallest positive double number is
in C in 32 bit CPU? cat main.c #include <stdio.h>
#include <float.h>

int main(int argc, char* argv[]) {
const
double x = DBL_MIN*DBL_EPS ILON;
const unsigned
long int* p = (const unsigned long int*)(&x);
fprintf(stdout, "x = %g\n", x);
fprintf(stdout, "p[1] = %lu\tp[0] = %lu\n", p[1], p[0]);
return 0;
}
gcc -Wall -std=c99 -pedantic -o main main.c
./main

x = 4.94066e-324
p[1] = 0 p[0] = 1
Nov 15 '05 #8
Jean-Claude Arbaut wrote:
You question is also tricky for another reason: usually a C compiler handles
float and double numbers, but the Pentium processor can work with extended
precision (that can be set by an asm instruction, maybe no accessible from
C, and certainly not in C standard).


long double?
Nov 15 '05 #9

On 23/06/2005 10:35, Grumble wrote:
Jean-Claude Arbaut wrote:
You question is also tricky for another reason: usually a C compiler handles
float and double numbers, but the Pentium processor can work with extended
precision (that can be set by an asm instruction, maybe no accessible from
C, and certainly not in C standard).


long double?


If the compiler knows of this type, yes.

Nov 15 '05 #10

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

Similar topics

2
8882
by: Keke922 | last post by:
I have to write a program that allows the user to enter a series of integers and -99 when they want to exit the loop. How do I display the largest and smallest number the user entered?
2
632
by: gouqizi.lvcha | last post by:
Hi, All: I wonder aht is the smallest positive double number in C++ under 32-bit CPU Rick
4
6478
by: Code4u | last post by:
I need to write an algorithm that sheds the outliers in a large data set, for example, I might want to ignore the smallest 2% of values and find the next smallest. Boost has a nth_element algorithm, however, it partially sorts the data. I have a requirement that the data remain in the orginal order. Of course I could make a copy of the vector or array and then apply nth_element, but this would be expensive in memory and would require...
7
5375
by: hasanainf | last post by:
Hi all, I have two querys QueryPurchased ProductID Location TotPcs Prod1 Loc1 100 Prod2 Loc1 50 Prod3 Loc1 150 Prod3 Loc3 150
13
5140
by: Peter Ammon | last post by:
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the given number is 1. Any suggestions? Thanks, -Peter
3
28180
by: Ken Durden | last post by:
Is it possible to force positive values to have the + sign prefixed on them? double f1 = 1024.2; double f2 = -1024.2; string.Format( "{0:F}", f1 ); // +1024.2 string.Format( "{0:F}", f2 ); // -1024.2 I was hoping for something either in the string.Format prefix, or
4
9821
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
6
4431
by: yokaygirl143 | last post by:
i am writing a simple java program but everything i do it seems to not work. i need to find the smallest and second smallest number in a set. please help me understand what i have done wrong. heres what i figured(but doesn't work fully): public class TwoSmallest { public static void main(String args) { int size = IO.readInt(); if (size <= 0)
63
5652
by: deepak | last post by:
Hi, Can someone give the standard function which can create positive integer value in C? Thanks, Deepak
0
8356
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,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
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,...
0
7387
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, 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...
0
4198
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...
1
2773
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.