Thread: [Dev-C++] Reading and printing long double values
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: André M. B. <and...@su...> - 2008-04-27 19:22:52
|
Dear users, I´m having some problems trying to read/print a long double value in C. Based on a documentation I´ve found, one of the attempts was: ... long double var=3.0; ... printf("printing a long double value-->%5.0Lg\n", var); ... I´ve already tested: %LE and %LF and none of these options worked. Does anybody know how to read and print? Thanks! Andre No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 09:39 |
From: Iván S. L. <iva...@gm...> - 2008-04-27 21:02:21
|
http://www.cplusplus.com/reference/clibrary/cstdio/printf.html André Macário Barros wrote: > Dear users, > > I´m having some problems trying to read/print > a long double value in C. > > Based on a documentation I´ve found, one of the > attempts was: > > ... > long double var=3.0; > ... > printf("printing a long double value-->%5.0Lg\n", var); > ... > > I´ve already tested: %LE and %LF and none of these > options worked. > > Does anybody know how to read and print? > Thanks! > > Andre > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 > 09:39 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > |
From: André M. B. <and...@su...> - 2008-04-27 21:57:07
|
Hi, Checking a little bit more, I found message #3 in which Ioannis Vranos said: http://www.velocityreviews.com/forums/t289111-printf-and-long-double.html Writing the same code in Borland, it worked fine! Thanks anyway! Andre -----Mensagem original----- De: Iván Sánchez Luque [mailto:iva...@gm...] Enviada em: domingo, 27 de abril de 2008 18:02 Para: André Macário Barros Cc: Lista do Dev-C++ Assunto: Re: [Dev-C++] Reading and printing long double values http://www.cplusplus.com/reference/clibrary/cstdio/printf.html André Macário Barros wrote: > Dear users, > > I´m having some problems trying to read/print > a long double value in C. > > Based on a documentation I´ve found, one of the > attempts was: > > ... > long double var=3.0; > ... > printf("printing a long double value-->%5.0Lg\n", var); > ... > > I´ve already tested: %LE and %LF and none of these > options worked. > > Does anybody know how to read and print? > Thanks! > > Andre > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 > 09:39 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao ne > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 09:39 No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 09:39 |
From: Per W. <pw...@ia...> - 2008-04-29 05:39:31
|
MinGW is using the M$ libraries, so to my knowledge it isn't possible to print a long double using printf(). Note that M$ does not distinguish between double and long double, so they don't have a need for a long double formatting prefix. /pwm On Sun, 27 Apr 2008, André Macário Barros wrote: > Dear users, > > I´m having some problems trying to read/print > a long double value in C. > > Based on a documentation I´ve found, one of the > attempts was: > > ... > long double var=3.0; > ... > printf("printing a long double value-->%5.0Lg\n", var); > ... > > I´ve already tested: %LE and %LF and none of these > options worked. > > Does anybody know how to read and print? > Thanks! > > Andre > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 > 09:39 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |
From: André M. B. <and...@su...> - 2008-04-30 15:03:19
|
But MigGW does this distinction. Please try: printf(sizeof(double)) and printf(sizeof(long double)) Does anybody know who wrote a printf or a full stdio.h (fprintf, sprintf, etc) which supports long doubles for MingGW? Regards André -----Mensagem original----- De: Per Westermark [mailto:pw...@ia...] Enviada em: terça-feira, 29 de abril de 2008 02:39 Para: André Macário Barros Cc: Lista do Dev-C++ Assunto: Re: [Dev-C++] Reading and printing long double values MinGW is using the M$ libraries, so to my knowledge it isn't possible to print a long double using printf(). Note that M$ does not distinguish between double and long double, so they don't have a need for a long double formatting prefix. /pwm On Sun, 27 Apr 2008, André Macário Barros wrote: > Dear users, > > I´m having some problems trying to read/print > a long double value in C. > > Based on a documentation I´ve found, one of the > attempts was: > > ... > long double var=3.0; > ... > printf("printing a long double value-->%5.0Lg\n", var); > ... > > I´ve already tested: %LE and %LF and none of these > options worked. > > Does anybody know how to read and print? > Thanks! > > Andre > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 > 09:39 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao ne > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > No virus found in this incoming message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.5/1401 - Release Date: 28/4/2008 07:18 No virus found in this outgoing message. Checked by AVG. Version: 7.5.524 / Virus Database: 269.23.6/1407 - Release Date: 30/4/2008 11:35 |
From: Per W. <pw...@ia...> - 2008-04-30 16:35:13
|
Yes, we are well aware that the MinGW compiler supports the long double data type as distinct from the double type. But the big question is: Why do you _need_ to print long double values? The double data type has 15 significant digits - is this really too little? The biggest reason for the long double data type is to get improved precision for internal values in numeric algorithms, where you may sum a nuge number of small numbers or where you may subtract similarly sized numbers and get calcellation effects. Most situations where the end result is expected to have 20 or more significant digits are well suited for big-number libraries and fixed-point arithmetic. Then you can produce results with 1000 or 1000000 significant digits if you want to. It doesn't matter how large fp data types you have available - floating point numbers can not store most values without rounding errors, and the conversion from binary format to decimal format done by printf() will result in rounding. The only question is how many correctly rounded digits you get. All you need to do to print your long double values are simple typecasts in the printf() calls. Your next alternative is to switch to cygwin instead. The cygwin library supports %Lg for printing extended-precision floating-point values. However, you must distribute your application with the cygwin support dll. /pwm On Wed, 30 Apr 2008, André Macário Barros wrote: > But MigGW does this distinction. > > Please try: > printf(sizeof(double)) and > printf(sizeof(long double)) > > Does anybody know who wrote a printf or > a full stdio.h (fprintf, sprintf, etc) which > supports long doubles for MingGW? > > Regards > André > > > -----Mensagem original----- > De: Per Westermark [mailto:pw...@ia...] > Enviada em: terça-feira, 29 de abril de 2008 02:39 > Para: André Macário Barros > Cc: Lista do Dev-C++ > Assunto: Re: [Dev-C++] Reading and printing long double values > > > MinGW is using the M$ libraries, so to my knowledge it isn't possible to > print a long double using printf(). > > Note that M$ does not distinguish between double and long double, so they > don't have a need for a long double formatting prefix. > > /pwm > > On Sun, 27 Apr 2008, André Macário Barros wrote: > > > Dear users, > > > > I´m having some problems trying to read/print > > a long double value in C. > > > > Based on a documentation I´ve found, one of the > > attempts was: > > > > ... > > long double var=3.0; > > ... > > printf("printing a long double value-->%5.0Lg\n", var); > > ... > > > > I´ve already tested: %LE and %LF and none of these > > options worked. > > > > Does anybody know how to read and print? > > Thanks! > > > > Andre > > > > No virus found in this outgoing message. > > Checked by AVG. > > Version: 7.5.524 / Virus Database: 269.23.5/1400 - Release Date: 27/4/2008 > > 09:39 > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > > Don't miss this year's exciting event. There's still time to save $100. > > Use priority code J8TL2D2. > > > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javao > ne > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > > No virus found in this incoming message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.5/1401 - Release Date: 28/4/2008 > 07:18 > > No virus found in this outgoing message. > Checked by AVG. > Version: 7.5.524 / Virus Database: 269.23.6/1407 - Release Date: 30/4/2008 > 11:35 > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by the 2008 JavaOne(SM) Conference > Don't miss this year's exciting event. There's still time to save $100. > Use priority code J8TL2D2. > http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |