Does the Standard specify any minimum range or minimum
precision for the float, double and long double. I haven't
found anything in the Standard about it.
-JKop 4 11780
> Does the Standard specify any minimum range or minimum precision for the float, double and long double. I haven't found anything in the Standard about it.
Yes: Float must offer at least the equivalent of 6 decimal digits of
precision; double and long double must offer at least the equivalent of 10
digits.
In practice, virtually all implementations use the machine's native
floating-point types; on most machines today those offer approximately 6
digits for float and 16 digits for double. Implementations are less
consistent for long double, but double is good enough for most applications
anyway.
"Andrew Koenig" In practice, virtually all implementations use the machine's native floating-point types; on most machines today those offer approximately 6 digits for float and 16 digits for double.
Borland C++ documents have always stated 7 for float and 15 for double.
Fraser.
On Sat, 07 Aug 2004 20:14:05 GMT, JKop <NU**@NULL.NULL > wrote in
comp.lang.c++: Does the Standard specify any minimum range or minimum precision for the float, double and long double. I haven't found anything in the Standard about it.
-JKop
This is one of those cases where the C++ standard adopts the
requirements of the C standard without repeating the text.
Section 5.2.4.2 Numerical limits spells out the minimum ranges for all
integer and floating point types, and minimum precision and several
other important factors for the floating point types. An
implementation, C or C++, is required to document its implementation.
The section number is the same in both the older version of the C
standard which the C++ standard includes, and the current C standard.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jack Klein posted: This is one of those cases where the C++ standard adopts the requirements of the C standard without repeating the text.
Section 5.2.4.2 Numerical limits spells out the minimum ranges for all integer and floating point types, and minimum precision and several other important factors for the floating point types. An implementation, C or C++, is required to document its implementation.
The section number is the same in both the older version of the C standard which the C++ standard includes, and the current C standard.
Great! Now all I need is the C Standard. What ever happened to self-
sufficency, self-containment?
-JKop This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: sriamar |
last post by:
Hello,
How does the type conversion work if the expression involves a float
and long int?
By K&R 2nd Ed i assume
float & long -> float & float .
But does the 'long' qualifier affect this in any way?. Because I dont
remember seeing something like 'long float ' anywhere and only 'long
|
by: maadhuu |
last post by:
hello ,
i would like to know as to why double is more efficient than float .
thanking you,
ranjan.
|
by: karthi |
last post by:
hi,
I need user defined function that converts string to float in c.
since the library function atof and strtod occupies large space in
my processor memory I can't use it in my code.
regards,
Karthi
|
by: abdul_n_khan |
last post by:
Hello,
I have a basic question related to datatypes.
I am trying to read a value using Microsoft's ADO recordset from a
field (lets call it 'Price') with datatype decimal(19,6) => 19 =
Precision, 6 = Scale
1) When I read this field into float datatype. I get a value 1.9000,
which is correct. But when I read its value in a double datatype I get
1.8999999761581.
|
by: ma740988 |
last post by:
Given:
void mxvmvd(double *pv1, long ninc1, double *pso, long n);
void mxvmvf( float *pv1, long ninc1, float *pso, long n);
How would I write a generic solution (template version) that'll call
the appropriate function based on the float or double type?
I've got vendor API's that has two separate functions that differ only
by 'f' (float) or 'd' (double). My intent is to put a wrappers around
these functions. I tempted to do a...
| |
by: Erick-> |
last post by:
hi all...
I've readed some lines about the difference between float and double
data types... but, in the real world, which is the best? when should we
use float or double??
thanks
Erick
|
by: Dilip |
last post by:
Recently in our code, I ran into a situation where were stuffing a
float inside a double. The precision was extended automatically
because of that. To make a long story short, this caused problems
elsewhere in another part of the system where that figure was used for
some calculation and some eventual truncation led to the system going
haywire. So my question is, given this code:
int main()
{
float f = 59.89F;
|
by: Carramba |
last post by:
Hi!
I now that I can't do straight forward any bitwise operation on float
(double etc..). But I wondering what is the easiest/best way to do this?
I was thinking if I have float x=1.1111 so I can multiple it by 1000 to
get 11111 and the preform bitwise like <<2 to get 88888 and then divide
by 1000 to go back to float 8.8888. but these seem like "nasty" way to
do it. So maybe some of you have great tips?
Thank you in advance!
L R
|
by: d major |
last post by:
I was very puzzled about the conversion between float and long, I
cann't understand why a long val can convert to a float, as the below
codes show:
typedef unsigned long u_long;
float val = 3.14159;
u_long nw_val = *((u_long *) &val);
than the nw_val equal to 1078530000, I made such conversion:
float d_val = *((float*)&nw_val);
|
by: Bill Reid |
last post by:
I just noticed that my "improved" version of sscanf() doesn't assign
floating point numbers properly if the variable assigned to is declared
as a "float" rather than a "double". (This never cropped up before, since
I rarely use "float"s for anything, and hardly ever use the function for
floating-point numbers in the first place; I just was messing around
testing it for all cases and noticed a problem.)
Anyway, it is declared and I...
|
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: 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...
|
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: 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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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.
| | |