long double in gcc implementations

L

lcw1964

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 provides the corresponding range and precision (up to 18
digits, with exponents up to about -/+ 4900) when compiled under an
older version of BC++.

In the MinGW incarnation of gcc, I have made a couple of adjustments to
get it to compile--in particular, _atold() doesn't exist, and atof() is
prototyped only in stdlib.h whereas in BC++ it is listed in math.h too.
However, I kept all of my long double declarations and outputs as that,
and used all of the long double versions of the math functions--expl(),
fabsl(), etc. The file complied but the output was gibberish. It took a
little googling to find that I had to recast the long double output as
double so printf() could meaningfully display it.

However, I have come to suspect that MinGW's long double isn't really
long double, and that somewhere in the process the range and precision
of of the floating point math has been restricted to the double range.
For example, in the original code under BC++ (not MSVC++, which is well
known to recast everything as double) I can generate a meaningful
answer of, say 1.34598900000098888e-2345, whereas the MinGW compiled
version will render this tiny value as simply 0.

My question is this--does MinGW offer the "true" long double floating
point 80bit type, and if so how can I get my programs to display
results of the sort I mentioned in the previous paragraph is printf()
needs recasting to double in order to handle it?

I know that the C language in general is not the best environment in
which to do extended precision math work (one would be better off
mastering a high or arbitrary precision library), but I would like to
get the most precision and range out of my calculations under MinGW if
this is available.

many thanks,

Les
 
J

jacob navia

lcw1964 a écrit :
I know that the C language in general is not the best environment in
which to do extended precision math work (one would be better off
mastering a high or arbitrary precision library), but I would like to
get the most precision and range out of my calculations under MinGW if
this is available.

The lcc-win32 C compiler offers 100 digits floats, 128 bit integers
bignums, whatever.

http://www.cs.virginia.edu/~lcc-win32

What mingw is concerned, please note that mingw uses the
run time library of microsoft, that does NOT support
long doubles, at least the last time I checked. There
are then several problems with that:
1) Maybe the compiler uses long doubles internally, but you can't
print them because printf does not understand long doubles.
You can check this by doing long double calculations and then
casting the result to double.
2) I think that mingw people started rewriting some stuff,
and porting glibc that uses its own internal routines
and definitely supports long doubles.
 
R

Richard Heathfield

jacob navia said:
lcw1964 a écrit :

The lcc-win32 C compiler offers 100 digits floats, 128 bit integers
bignums, whatever.

More irrelevant spam from Jacob Navia. Enough is enough. I have removed the
lcc-win32 link from my Web site's list of compilers. It will return when
Jacob gets a clue (i.e. probably never).

<snip>
 
L

lcw1964

Whoa whoa whoa!

I have just downloaded lcc-win32 and it looks pretty cool, with a lot
of nifty extended math functions and and not bad GUI for software which
for me, as a non-business user, is free.

Did I just wade into a political rats' nest here?

Les
 
E

Eric Sosman

lcw1964 said:
Whoa whoa whoa!

I have just downloaded lcc-win32 and it looks pretty cool, with a lot
of nifty extended math functions and and not bad GUI for software which
for me, as a non-business user, is free.

Fine. Use it good health. However, keep in mind that
this compiler (if we are to believe Jacob's description) is
not a C compiler, at least, not a C compiler in its usual
mode of operation. It's some kind of C-plus-extra-goodies
compiler, and if you get hooked on the goodies you may find
that your code won't run on any other systems.

That may or may not be a problem for you; portability is
not the only desirable feature of a piece of code, and is
in some cases worth sacrificing. Just realize that you aren't
getting something for nothing; there's a price to be paid. If
you feel the benefits are worth the price, go ahead and pay --
that's what commerce is all about -- just don't put it on the
ol' credit card and imagine it was free.
Did I just wade into a political rats' nest here?

Jacob has a history of promoting his compiler, especially
to newcomers who may be unwary. He extols its features, he
brags about the latest doodad he's added -- and he claims all
this stuff is "C" simply because his compiler, somewhere back
in its genetic makeup, once had a "C" label attached to it. The
upshot is that nearly every time he posts, other people have to
spend time writing warnings like this one, warnings that would
be unnecessary if he would describe his C-plus-gimmicks accurately.

But, no. In his message on this thread (only his first on
this thread, I fear), he specifically described lcc-win32 as
a "C compiler." It may actually be capable of compiling C, but
he's encouraging you to use "100 digits floats, 128 bit integers
bignums, whatever." The "whatever" alone should raise red flags.

"When in doubt, treat ``feature'' as a pejorative.
(Think of a hundred-bladed Swiss army knife.)"
--Kernighan and Plauger, "Software Tools"
 
T

Tom St Denis

lcw1964 said:
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 provides the corresponding range and precision (up to 18
digits, with exponents up to about -/+ 4900) when compiled under an
older version of BC++.

Since nobody else brought this up...

Have you thought of trying out Cygwin? It gives you a nice UNIX
emulation layer on-top of the windows runtime (e.g. applications you
write in Cygwin stand half a chance of working on BSD, Linux and UNIX).

I don't know for a fact, but maybe the math libs linked in with Cygwin
can help you out.

Tom
 
J

jacob navia

lcw1964 a écrit :
Whoa whoa whoa!

I have just downloaded lcc-win32 and it looks pretty cool, with a lot
of nifty extended math functions and and not bad GUI for software which
for me, as a non-business user, is free.

Did I just wade into a political rats' nest here?

Les

Yes. There is a political rat's nest here.

Some people in this group, think that lcc-win32 is a bad compiler
since it has good features in it.

As you know, good features in a copmpiler are bad because
you will use them and like them. The theory goes, you
will get hooked by those evil features, and you will not be
able to use other compilers that do not have them.

You know, it is like ice cream in summer. You like it, and then,
you want more of it.

So, the theory goes, you should not eat ice cream in summer
but hot soup.

But do not worry. Download rates of my compiler system are
anormous, and there are many people using it.

It is widely used in teaching, and many universities have bought
licenses for it.

Just use it. I think you will like it because there are features
like 100 digit precision floats that you will be pressed to find
elsewhere. The math libraries are very extended, as you have noticed.
 
R

Richard Heathfield

jacob navia said:
lcw1964 a écrit :

Yes. There is a political rat's nest here.

Some people in this group, think that lcc-win32 is a bad compiler
since it has good features in it.

No, you unutterably stupid man. What we think is bad is your apparent belief
that "C" and "lcc-win32-with-all-its-doodads" are synonymous. They are not.
What we also think is bad is your promotion of non-portable lcc-win32
features in a group where portability is considered very important. If you
want to promote your "good features", the appropriate group in which to do
so is a newsgroup where such features are topical, which is not
comp.lang.c, you unutterably stupid man. And who would want to use a
compiler written by an unutterably stupid man?
As you know, good features in a copmpiler are bad because
you will use them and like them.

No, you unutterably stupid man. Good features in a compiler are fabulous and
wonderful and lovely, as long as you can turn them off when you want to
write portable code. But those features that render the implementation
non-conforming are not topical in the comp.lang.c newsgroup, and that is
why we object to their being discussed here in the comp.lang.c newsgroup,
you unutterably stupid man. And who would want to use a compiler written by
an unutterably stupid man?
 
T

Tom St Denis

jacob said:
Yes. There is a political rat's nest here.

Some people in this group, think that lcc-win32 is a bad compiler
since it has good features in it.

And to think I remember a time when "lcc" referred to an ANSI-C
compiler...
But do not worry. Download rates of my compiler system are
anormous, and there are many people using it.

So what? How many commercial products are made with it? I don't know
of a single shop that uses lcc-win32. They all pretty much use VS and
failing that Cygwin.

I think you really should rename the project if you want to keep up
this crap. Call it JN-Win32 or something. It's clearly not a C
compiler anymore.

I'm half tempted to think this isn't the "real" jacob. Seems like a
clever joe-job.

Tom
 
E

Eric Sosman

jacob said:
[...]
You know, it is like ice cream in summer. You like it, and then,
you want more of it.

So, the theory goes, you should not eat ice cream in summer
but hot soup.

I wasn't thinking of ice cream, actually, but of Kool-Aid.
(It wasn't actually Kool-Aid at the Jonestown Massacre, but
the phrase has outrun any casual connection to truth in much
the same way lcc-win32 has outrun any casual connection to C.)
 
S

Skarmander

Richard Heathfield wrote:
[lots of repetitions of the phrase "unutterably stupid man" addressed to
Jacob Navia]

Please try making your points without calling people names. It's childish
and distracting. I don't frequent comp.lang.c for the arguments, but when
there *are* arguments I'd at least expect the participants to remain civil.

Calling mr. Navia "unutterably stupid" as many times as possible is for your
own benefit, as nobody expects such epithets to convince anyone of anything,
except perhaps the immaturity of the speaker. That he was being disingenuous
by deliberately misrepresenting your (and other people's) views doesn't
change that.

In short, if you want to insult someone on a personal level, please use
e-mail. I'm pretty sure your post would have conveyed its non-personal
points equally well without the insults.

S.
 
J

jacob navia

Eric Sosman a écrit :

I answer to you Eric because there were no insults in
your post. Others, I will just ignore.

You wrote:

lcc-win32 has outrun any casual connection to C.)


In the C standard it is specified in 6.11:

< quote >
6.11 Future language directions
6.11.1 Floating types
1 Future standardization may include additional floating-point types,
including those with greater range, precision, or both than long double.
< end quote >

Lcc-win32 follows this directive. The floating point type "qfloat",
conforms precisely to the usage of other floating point types.

Lcc-win32 specializes in providing the highest support that C can
provide to mathematical users. Together with the qfloat type
an int128 type is provided.

There is nothing in the C standards that specifically
forbids adding extended mathematical types or new kind
of numbers. In general, extensions are NOT forbidden.

In the C standard we read in Paragraph 4: Conformance:

< quote >
A conforming implementation may have extensions (including additional
library functions), provided they do not alter the behavior of any
strictly conforming program.
< end quote >

This is clear. My implementation remains conforming. If you do not
want to use qfloats nobody forces you to.

Concerning the argument that "this group is about standard c"
I have countless times repeated that there is NO LEGAL BASIS
for that since this group has no chart. This is Usenet and
I can express my opinion about this or that as I wish without
anybody having to get upset.

Sincerely

Jacob
 
R

Richard Heathfield

Tom St Denis said:

So what? How many commercial products are made with it? I don't know
of a single shop that uses lcc-win32. They all pretty much use VS and
failing that Cygwin.

For Windows, you're pretty much right, although Borland does keep popping up
in odd places. Of course, the visibly commercial world is dominated by
Windows, but there are other commercial avenues. I've worked in a number of
places that use gcc under Linux to write applications that are most
assuredly commercial in nature.

The mainframe C world is, in my experience at least, mostly C/370 and LE370.
Most mainframe programs are for in-house use, obviously, but even mainframe
installations buy in software, and there is a commercial mainframe software
market to meet that need.
 
S

Skarmander

jacob said:
This is Usenet and I can express my opinion about this or that as I wish
without anybody having to get upset.
With all due respect, that statement is a contradiction in terms. This *is*
Usenet...

S.
 
J

jacob navia

Skarmander a écrit :
With all due respect, that statement is a contradiction in terms. This
*is* Usenet...

S.

I do not understand you but anyway, what I wanted to say is that
in the internet groups (that I have been reading and using
since beginning of the 90ties) everybody can express his/her
opinions.

True, I speak about my compiler system in this group, and I think that I
have the right to do so. Specifically, when a user has precision
problems, I think I can point out that after years of effort I have a
compiler system that offers 100 digits in the standard version.

With the growth of the machine power at our disposal, it is increasingly
obvious that we could USE that computing power more, to do calculations
at a level of precision and exactness that wasn't possible in the
times of the PDP 11.

And I think that C, with its emphasis in raw power is the right language
to provide such an extension.

Why should we settle for long double when we can have much more?

A more precise floating type, besides, is mentioned in the C standard.
In the C standard it is specified in 6.11:

< quote >
6.11 Future language directions
6.11.1 Floating types
1 Future standardization may include additional floating-point types,
including those with greater range, precision, or both than long double.
< end quote >

Lcc-win32 follows this directive. The floating point type "qfloat",
conforms precisely to the usage of other floating point types.

This is obviously my personal opinion and I respect anyone who
disagrees with me. As you may have noticed, my posts do not
contain insults or personal attacks to anyone, not even with
people that have a long record of polemic.
 
R

Richard Heathfield

Skarmander said:
Richard Heathfield wrote:
[lots of repetitions of the phrase "unutterably stupid man" addressed to
Jacob Navia]

Please try making your points without calling people names. It's childish
and distracting. I don't frequent comp.lang.c for the arguments, but when
there *are* arguments I'd at least expect the participants to remain
civil.

It's a reasonable objection, and you do have a point. But...

(a) Lots of worse things have been said here by other people, including Mr
Navia himself, to which you did not object. Why now, and why this?
(b) Either Mr Navia is being stupid or he's using comp.lang.c for commercial
gain. In other words, his constant plugging of lcc-win32's non-portable
features here is either through malice or because of incompetence. I used
Hanlon's Razor.
(c) Some readers of comp.lang.c are clearly not aware of Mr Navia's
continued abuse of this newsgroup, as we have seen in this very thread. I
thought it helpful to draw their attention to one or two examples of the
sloppy thinking Mr Navia constantly displays.
(d) I think many people here would agree that I am one of the more patient
of comp.lang.c's regular contributors (not as patient as Chris Torek, of
course, but then not even Chris Torek is as patient as Chris Torek). That
Mr Navia should provoke such a reaction in a normally patient subscriber
should in itself ring some alarm bells for potential lcc-win32 users.
Calling mr. Navia "unutterably stupid" as many times as possible is for
your own benefit,

Not as many times as possible, by any means. And certainly not for my own
benefit. If I want to call people names for my own benefit, I can do that
offline.
 
S

Skarmander

jacob said:
Skarmander a écrit :

I do not understand you but anyway, what I wanted to say is that
in the internet groups (that I have been reading and using
since beginning of the 90ties) everybody can express his/her
opinions.
I'll be more explicit: your remark that you can "express [your] opinion
about this or that as I wish without anybody having to get upset" is so
obviously flawed! This is Usenet, of course people will get upset at
opinions, about anything from euthanasia to knitting patterns. I *think*
flame wars were invented on Usenet, too, but they might be older.

Do they *have* to get upset? Well, probably. It's human nature.
True, I speak about my compiler system in this group, and I think that I
have the right to do so. Specifically, when a user has precision
problems, I think I can point out that after years of effort I have a
compiler system that offers 100 digits in the standard version.
And so you did. What one is entitled to (or believes oneself to be entitled
to) is of no concern on Usenet.
With the growth of the machine power at our disposal, it is increasingly
obvious that we could USE that computing power more, to do calculations
at a level of precision and exactness that wasn't possible in the
times of the PDP 11.

And I think that C, with its emphasis in raw power is the right language
to provide such an extension.

Why should we settle for long double when we can have much more?
You're asking the wrong question, and ignoring the points made.

Nobody should fault you for mentioning compiler-specific extensions, as long
as you clearly mention, in ten feet high burning letters, that they *are*
compiler-specific extensions. To simply mention that "my compiler supports
this awesome feature that might be of use to you", without also clearly
mentioning that you're going outside the realm of standard C, is
disingenuous. There are solid reasons the group generally prefers sticking
to standard C, and acknowledging this preference is just a matter of good
manners, especially when making remarks that are self-serving.
A more precise floating type, besides, is mentioned in the C standard.
In the C standard it is specified in 6.11:

< quote >
6.11 Future language directions
6.11.1 Floating types
1 Future standardization may include additional floating-point types,
including those with greater range, precision, or both than long double.
< end quote >

Lcc-win32 follows this directive. The floating point type "qfloat",
conforms precisely to the usage of other floating point types.
Whoa there. This is *not* a directive, and not directed at you in any case.
You are indeed free to implement nonstandard floating point types, but that
is not a result of the section you quoted. That merely says that the
standards committee may add more types in the future. That implementations
may provide extensions so long as this doesn't affect conforming programs is
mentioned elsewhere.
This is obviously my personal opinion and I respect anyone who
disagrees with me. As you may have noticed, my posts do not
contain insults or personal attacks to anyone, not even with
people that have a long record of polemic.

Duly noted, but this does not give you any sort of moral high ground.

S.
 
L

lcw1964

Thanks, and I know I should try it out, but I must admit that I am
Unix/Linux impaired (I am writing here as an amateur and hobbyist, so
if I should take my query to a more appropriate NG please advise) and I
have not found Cygwin as easy to install as MinGW, which provides all I
need in a couple of self-contained EXEs. The bottom line is that there
a many file choices offered in any cygwin download, and I have no clue
what I need, so I will do a little research first.

I am an evil windows user and am writing only for myself, so I don't
care about cross-platform compatibility, but I do want a long double
type that "means" long double. I understand that MinGW may have a
dependency on msvcrt.dll that casts long double to double.

Les
 
S

Skarmander

Richard said:
Skarmander said:
Richard Heathfield wrote:
[lots of repetitions of the phrase "unutterably stupid man" addressed to
Jacob Navia]

Please try making your points without calling people names. It's childish
and distracting. I don't frequent comp.lang.c for the arguments, but when
there *are* arguments I'd at least expect the participants to remain
civil.

It's a reasonable objection, and you do have a point. But...

(a) Lots of worse things have been said here by other people, including Mr
Navia himself, to which you did not object. Why now, and why this?

Phase of the moon. I'm not singling you out, if that's what you think. This
post just leapt at me. I'm not usually a net.nanny, but I personally dislike
reading childish bickering, and I may make the occasional remark.
(b) Either Mr Navia is being stupid or he's using comp.lang.c for commercial
gain. In other words, his constant plugging of lcc-win32's non-portable
features here is either through malice or because of incompetence. I used
Hanlon's Razor.
(c) Some readers of comp.lang.c are clearly not aware of Mr Navia's
continued abuse of this newsgroup, as we have seen in this very thread. I
thought it helpful to draw their attention to one or two examples of the
sloppy thinking Mr Navia constantly displays.
(d) I think many people here would agree that I am one of the more patient
of comp.lang.c's regular contributors (not as patient as Chris Torek, of
course, but then not even Chris Torek is as patient as Chris Torek). That
Mr Navia should provoke such a reaction in a normally patient subscriber
should in itself ring some alarm bells for potential lcc-win32 users.
I don't fault you for expressing your opinion (and I do see your point); I
was just slightly put off by the style.
Not as many times as possible, by any means. And certainly not for my own
benefit. If I want to call people names for my own benefit, I can do that
offline.
Alright, so you really *were* trying to convince people he's unutterably
stupid. My mistake...

S.
 
R

Richard Heathfield

jacob navia said:

This is obviously my personal opinion and I respect anyone who
disagrees with me. As you may have noticed, my posts do not
contain insults or personal attacks to anyone, not even with
people that have a long record of polemic.

"Genius programmers like you should not use lcc-win32." - Jacob Navia.
"Excuse me sir. Should I speak to you as "your holiness" maybe ?" - Jacob
Navia.
"Your language (hopes to cover his silly ass, etc) just shows your anal
fixation... Go to a doctor man." - Jacob Navia.
"Please turn on your brain before complaining..." - Jacob Navia.

etc etc ad nauseam.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top