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

long double

Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Apr 7 '08 #1
15 2997
broli wrote:
Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
It has been a part of all C language standards: ISO C90, C95, C99.
Apr 7 '08 #2

"broli" <Br*****@gmail.comwrote in message news:
Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Basically it's a hardware question. Whilst floating point can be emulated in
software, if you have to do this it's unlikely that you need much precision.
If the hardware supports 80 bit floats then the C compiler has to support
them, in practise, or people would complain. I think it is actually part of
C99, for what it's worth, but that standard hasn't received wide acceptance,
so it doesn't really matter whether long double is in it or not.

--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

Apr 7 '08 #3
Malcolm McLean wrote:
"broli" <Br*****@gmail.comwrote in message news:
>Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Basically it's a hardware question. Whilst floating point can be emulated in
software, if you have to do this it's unlikely that you need much precision.
If the hardware supports 80 bit floats then the C compiler has to support
them, in practise, or people would complain. I think it is actually part of
C99, for what it's worth, but that standard hasn't received wide acceptance,
so it doesn't really matter whether long double is in it or not.
You seem to be confused about what 'long double' means. There is no
requirement that long double be at least 80 bits. Although long double
is part of C99, it is not guaranteed to be any larger or store any more
values than double.

Philip
Apr 7 '08 #4
broli wrote:
Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
long double is part of C99

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Apr 7 '08 #5
Malcolm McLean wrote:
>
"broli" <Br*****@gmail.comwrote in message news:
>Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Basically it's a hardware question.
No, the question was about the standard. The questions is
Are "long double"s part of C99?

There is no hint as to any hardware questions.
Whilst floating point can be
emulated in software, if you have to do this it's unlikely that you need
much precision. If the hardware supports 80 bit floats then the C
compiler has to support them, in practise, or people would complain.
No, this is completely wrong. The compiler can IGNORE them and if people
complain the compiler builders will not give a damm.

Example at hand: In Microsoft compilers, long double is the same as
double. The users are complaining since 10 years and they go on.
I
think it is actually part of C99, for what it's worth, but that standard
hasn't received wide acceptance, so it doesn't really matter whether
long double is in it or not.
And your opinion about C99 matters even less.

C99 is the current C standard, even if you persist on trying to
disqualify it.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Apr 7 '08 #6
jacob navia <ja***@nospam.comwrites:
broli wrote:
>Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?

long double is part of C99
Yes. long double is (was?) also part of C89/C90, and I'm reasonably
sure that the requirements for C90 did not change between C90 and C99.
C99 did make a minor change in the printf formats for long double, and
added math functions for long double, but made no change in the type
itself.

I don't know where this idea that long double is a C99-specific
feature came from, but it's mistaken. (I'm not suggesting that jacob
made this mistake; I'm just providing additional information.)

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 7 '08 #7

"broli" <Br*****@gmail.comwrote in message
news:eb**********************************@q27g2000 prf.googlegroups.com...
Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Long double seems to be part of both C90 and C99 standards. And in both it
seems to be at least 32-bits.

Whether you get any more precision depends on your compiler, but it may not
necessarily be more than double.

--
Bart
Apr 7 '08 #8
Bartc wrote:
"broli" <Br*****@gmail.comwrote in message
news:eb**********************************@q27g2000 prf.googlegroups.com...
>Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?

Long double seems to be part of both C90 and C99 standards.
Yes.
And in both it
seems to be at least 32-bits.
This needs some explanation. There must be at least
LDBL_DIG * lg(10) bit-equivalents in the fractional part
of a long double, and since LDBL_DIG must be at least 10
this implies a fraction of at least 33.2+ bit-equivalents.
There must also be enough distinct exponent values to cover
the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP, which
must be at least the range -37 through +37; 75 or more
distinct values implies lg(75) = 6.2+ bit-equivalents.
Finally there's the sign, for one more bit-equivalent. All
in all, long double needs at least 40.4+ bit-equivalents.

Since 40.4+ is "at least 32," you're right.
Whether you get any more precision depends on your compiler, but it may not
necessarily be more than double.
Right: the minimum requirements for long double's range
and precision are the same as those for plain double, so the
implementation is not obliged to do any better. It must not
do any worse, though.

--
Er*********@sun.com
Apr 7 '08 #9
Eric Sosman wrote:
Bartc wrote:
>"broli" <Br*****@gmail.comwrote in message
news:eb**********************************@q27g200 0prf.googlegroups.com...
>>Is this a part of C 99 or just an addon in some windows compilers like
pellesC ?
Long double seems to be part of both C90 and C99 standards.

Yes.
>And in both it
seems to be at least 32-bits.

This needs some explanation. There must be at least
LDBL_DIG * lg(10) bit-equivalents in the fractional part
of a long double, and since LDBL_DIG must be at least 10
this implies a fraction of at least 33.2+ bit-equivalents.
No, you only need (LDBL_DIG * lg(10) - 1) bit-equivalents in binary. In
binary floating point, the most significant bit is always 1 except for
unnormalised numbers, infinities, NaNs, and zero. The first three aren't
required to exist, and the minimum possible value can be defined to be zero.
There must also be enough distinct exponent values to cover
the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP, which
must be at least the range -37 through +37; 75 or more
distinct values implies lg(75) = 6.2+ bit-equivalents.
Finally there's the sign, for one more bit-equivalent. All
in all, long double needs at least 40.4+ bit-equivalents.

Since 40.4+ is "at least 32," you're right.
And hence I think you only need 39.4 bits in binary (and even in other
radices, you could probably exploit the fact that the most significant
digit is nonzero to reduce the requirement below 40.4 bits).
>Whether you get any more precision depends on your compiler, but it may not
necessarily be more than double.

Right: the minimum requirements for long double's range
and precision are the same as those for plain double, so the
implementation is not obliged to do any better. It must not
do any worse, though.
Indeed. The set of double values are a subset of long double values.

Philip
Apr 7 '08 #10
On Mon, 07 Apr 2008 14:40:55 -0400, Eric Sosman <Er*********@sun.com>
wrote:
Bartc wrote:
<snip[long double] seems to be at least 32-bits.

This needs some explanation. There must be at least
LDBL_DIG * lg(10) bit-equivalents in the fractional part
of a long double, and since LDBL_DIG must be at least 10
this implies a fraction of at least 33.2+ bit-equivalents.
Possibly minus 1 for hidden-bit, as already discussed.
There must also be enough distinct exponent values to cover
the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP, which
must be at least the range -37 through +37; 75 or more
distinct values implies lg(75) = 6.2+ bit-equivalents.
There is no need for the exponent's base to be 10. Commonly it is 2
(which allows maximum density of a binary significand, and hidden-bit)
and a dynamic range of 1e-/+37 is roughly 2 up -/+123 for 8 bits of
exponent. But S/360 uses 16 (as you noted) and needs only 6 bits of
exponent for the same range. And it would be legal to use a larger
base, but the loss in significand precision grows much faster than the
gain in reduced exponent size, so people don't.

<snip rest>
- formerly david.thompson1 || achar(64) || worldnet.att.net
Jun 27 '08 #11
"David Thompson" <da************@verizon.netwrote in message
news:di********************************@4ax.com...
On Mon, 07 Apr 2008 14:40:55 -0400, Eric Sosman <Er*********@sun.com>
wrote:
>Bartc wrote:
<snip[long double] seems to be at least 32-bits.

This needs some explanation. There must be at least
LDBL_DIG * lg(10) bit-equivalents in the fractional part
of a long double, and since LDBL_DIG must be at least 10
this implies a fraction of at least 33.2+ bit-equivalents.

Possibly minus 1 for hidden-bit, as already discussed.
>There must also be enough distinct exponent values to cover
the range LDBL_MIN_10_EXP through LDBL_MAX_10_EXP, which
must be at least the range -37 through +37; 75 or more
distinct values implies lg(75) = 6.2+ bit-equivalents.

There is no need for the exponent's base to be 10. Commonly it is 2
(which allows maximum density of a binary significand, and hidden-bit)
and a dynamic range of 1e-/+37 is roughly 2 up -/+123 for 8 bits of
exponent. But S/360 uses 16 (as you noted) and needs only 6 bits of
exponent for the same range. And it would be legal to use a larger
base, but the loss in significand precision grows much faster than the
gain in reduced exponent size, so people don't.
I guess it is not true on a binary machine, but I once saw a proof that
maximum information density requires base e (and therefore, for integral
bases, 3 is a bit more compact than binary since it is closer to e than 2
is.) I guess that a ternary machine would be needed to express the data
most compactly using this representation.
** Posted from http://www.teranews.com **
Jun 27 '08 #12
Dann Corbit wrote:
>
.... snip ...
>
I guess it is not true on a binary machine, but I once saw a proof
that maximum information density requires base e (and therefore,
for integral bases, 3 is a bit more compact than binary since it
is closer to e than 2 is.) I guess that a ternary machine would
be needed to express the data most compactly using this
representation.
And then you have to consider the added physical complexity of
building a flip-flap-flop (in place of a flip-flop), and
implementing tri-level gates, etc.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #13
On Apr 22, 2:21*pm, CBFalconer <cbfalco...@yahoo.comwrote:
Dann Corbit wrote:

... snip ...
I guess it is not true on a binary machine, but I once saw a proof
that maximum information density requires base e (and therefore,
for integral bases, 3 is a bit more compact than binary since it
is closer to e than 2 is.) *I guess that a ternary machine would
be needed to express the data most compactly using this
representation.

And then you have to consider the added physical complexity of
building a flip-flap-flop (in place of a flip-flop), and
implementing tri-level gates, etc.
With +voltage, ground, -voltage the idea is so obvious I would guess
someone has tried it.
Jun 27 '08 #14
On Apr 22, 3:31*pm, user923005 <dcor...@connx.comwrote:
On Apr 22, 2:21*pm, CBFalconer <cbfalco...@yahoo.comwrote:
Dann Corbit wrote:
... snip ...
I guess it is not true on a binary machine, but I once saw a proof
that maximum information density requires base e (and therefore,
for integral bases, 3 is a bit more compact than binary since it
is closer to e than 2 is.) *I guess that a ternary machine would
be needed to express the data most compactly using this
representation.
And then you have to consider the added physical complexity of
building a flip-flap-flop (in place of a flip-flop), and
implementing tri-level gates, etc.

With +voltage, ground, -voltage the idea is so obvious I would guess
someone has tried it.
http://en.wikipedia.org/wiki/Setun
Jun 27 '08 #15
In article <48***************@yahoo.comcb********@maineline.net writes:
Dann Corbit wrote:
....
I guess it is not true on a binary machine, but I once saw a proof
that maximum information density requires base e (and therefore,
for integral bases, 3 is a bit more compact than binary since it
is closer to e than 2 is.) I guess that a ternary machine would
be needed to express the data most compactly using this
representation.

And then you have to consider the added physical complexity of
building a flip-flap-flop (in place of a flip-flop), and
implementing tri-level gates, etc.
Has been done, and it was apparently not so very difficult.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jun 27 '08 #16

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

Similar topics

17
by: Suzanne Vogel | last post by:
I'd like to convert a double to a binary representation. I can use the "&" bit operation with a bit mask to convert *non* float types to binary representations, but I can't use "&" on doubles. ...
12
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
3
by: RoSsIaCrIiLoIA | last post by:
I have rewrote the malloc() function of K&R2 chapter 8.7 typedef long Align; ^^^^ Here, should I write 'long', 'double' or 'long double'? I know that in my pc+compiler sizeof(long)=4,...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
5
by: Daniel Rudy | last post by:
How does one covert a interger number in a unsigned long long int (64-bit) to long double (80-bit) storage? I looked at math.h and I found function that convert double to long long, but didn't...
10
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
69
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after...
67
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...
52
by: lcw1964 | last post by:
Greetings, all, I am trying to port a little bit of math code to gcc, that in the original version used the long double version of several functions (in particular, atanl, fabsl, and expl). I...
10
by: ratcharit | last post by:
Currently using cosine function in math.h Currently I get: 1 = cos(1e^-7) Is there another way for cos to return value of high accuracy say: 0.999999 = cos(1e^-7)
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.