473,406 Members | 2,451 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,406 software developers and data experts.

float, double, long double


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
Jul 22 '05 #1
4 11763
> 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.
Jul 22 '05 #2

"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.
Jul 22 '05 #3
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.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Jul 22 '05 #4
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
Jul 22 '05 #5

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

Similar topics

2
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...
13
by: maadhuu | last post by:
hello , i would like to know as to why double is more efficient than float . thanking you, ranjan.
6
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,...
8
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,...
1
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...
60
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
116
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...
45
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...
8
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 =...
22
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...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
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,...
0
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...
0
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...
0
tracyyun
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...

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.