473,614 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"long double" and "printf"

Hi everybody,

i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.

For int the command could be:

printf("\n%20s\ t%7u\t%13i\t%13 i","signed int",sizeof(sig ned
int),INT_MIN,IN T_MAX);

But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.

Thanks for your help!

Jun 6 '06 #1
12 43427
Zero wrote:

Hi everybody,

i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.

For int the command could be:

printf("\n%20s\ t%7u\t%13i\t%13 i","signed int",sizeof(sig ned
int),INT_MIN,IN T_MAX);

But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.


For something like that,
you should try to post a complete program.

/* BEGIN new.c */

#include <stdio.h>
#include <float.h>

int main(void)
{
printf("%s\n%u\ n%Le\n%Le\n",
"long double",
(unsigned)sizeo f(long double),
LDBL_MIN,
LDBL_MAX);
return 0;
}

/* END new.c */
--
pete
Jun 6 '06 #2

pete wrote:
Zero wrote:

Hi everybody,

i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.

For int the command could be:

printf("\n%20s\ t%7u\t%13i\t%13 i","signed int",sizeof(sig ned
int),INT_MIN,IN T_MAX);

But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.


For something like that,
you should try to post a complete program.

/* BEGIN new.c */

#include <stdio.h>
#include <float.h>

int main(void)
{
printf("%s\n%u\ n%Le\n%Le\n",
"long double",
(unsigned)sizeo f(long double),
LDBL_MIN,
LDBL_MAX);
return 0;
}

/* END new.c */
--
pete


Thanks for your help. But i still get this message:

long double
12
0.000000e+000
-1.#QNAN0e+000

??

Jun 6 '06 #3
"Zero" <ch********@web .de> wrote:
But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.


AFAICT this is a bug in Dev-C++. Their library and their headers don't
match on this detail. One (IIRC the header) thinks long doubles are
larger than doubles, the other (IIRC the printf() code) thinks they're
as large as doubles.

Richard
Jun 6 '06 #4
In article <11************ *********@h76g2 000cwa.googlegr oups.com> "Zero" <ch********@web .de> writes:
....
Thanks for your help. But i still get this message:

long double
12
0.000000e+000
-1.#QNAN0e+000


Some older compilers did use 'll' in stead of 'L' for long double.
--
dik t. winter, cwi, kruislaan 413, 1098 sj amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn amsterdam, nederland; http://www.cwi.nl/~dik/
Jun 6 '06 #5

Zero wrote:
Hi everybody,

i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.

For int the command could be:

printf("\n%20s\ t%7u\t%13i\t%13 i","signed int",sizeof(sig ned
int),INT_MIN,IN T_MAX);

But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.

Thanks for your help!


I just tried the code with Visual C++ and there it seems
that there is no difference between double and long double?

Bloodshed says long double consists of 12 Bytes, Visual C++ says 12.
What is right now?

Jun 6 '06 #6

Zero wrote:
Hi everybody,

i want to write a small program, which shows me the biggest and
smallest number in dependance of the data type.

For int the command could be:

printf("\n%20s\ t%7u\t%13i\t%13 i","signed int",sizeof(sig ned
int),INT_MIN,IN T_MAX);

But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.

Thanks for your help!


I just tried the code with Visual C++ and there it seems
that there is no difference between double and long double?

Bloodshed says long double consists of 12 Bytes, Visual C++ says 8.
What is right now?

Jun 6 '06 #7

Richard Bos wrote:
"Zero" <ch********@web .de> wrote:
But what do I have to do when I want to print out the numbers of data
type "long double".

I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.


AFAICT this is a bug in Dev-C++. Their library and their headers don't
match on this detail. One (IIRC the header) thinks long doubles are
larger than doubles, the other (IIRC the printf() code) thinks they're
as large as doubles.

Richard


How do you know that this is a bug? Is there a side, where this
information can be fetched?

Jun 6 '06 #8
Zero wrote:

<snip>
I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.

Thanks for your help!


I just tried the code with Visual C++ and there it seems
that there is no difference between double and long double?

Bloodshed says long double consists of 12 Bytes, Visual C++ says 8.
What is right now?


Both. The C standard does not mandate exact sizes only minimums.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jun 6 '06 #9
Flash Gordon wrote:
Zero wrote:

<snip>
I tried
printf("\n%20s\ t%7u\t%13Lf\t%1 3Lf","long double",sizeof( long
double),LDBL_MI N,LDBL_MAX);
but this results in

long double 12 0.000000 -1.#QNAN0

Does anybody has a solution.

I tried this with Bloodshed using the gnu-compiler.

Thanks for your help!


I just tried the code with Visual C++ and there it seems
that there is no difference between double and long double?

Bloodshed says long double consists of 12 Bytes, Visual C++ says 8.
What is right now?


Both. The C standard does not mandate exact sizes only minimums.

Besides, the amount of unused storage doesn't directly answer your
problem. Few of us would know whether specifying Bloodshed implies a
specific version of gcc and run-time library. Run-time libraries
associated with Windows versions of gcc which I have used didn't
implement 10-byte long double in printf(), even though it might be
supported in terms of basic operators. If it uses Visual C++ printf(),
evidently there will be no support for more than 8-byte data type.
Jun 6 '06 #10

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

Similar topics

5
22942
by: Piotr B. | last post by:
Hello, I use MingGW g++ 3.2.3 on Windows 2000/AMD Athlon XP. I tried to output a "long double" variable using stdio printf(). I've tried various %formats (%llf, %Lf etc.), but none of them worked... The same source compiled with Borland C++Builder 5.0 works for %Lf format. How to get the same results with MinGW g++ ?
22
3696
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as <math.h> and <tgmath.h> are concerned? What wintel compilers support a 16-byte "long double" (with 33 decimal digits of accuracy) including proper printf() support. I found some compilers that did support "long double", but theirs was an 8-byte or 10-byte or 12-byte type with accuracy the...
2
2303
by: Jude | last post by:
here is the source code: #include<stdio.h> int main() { float f; scanf("%d%f",&f); printf("The float is %10.5f\n",f); return 0; } when I input 12345.11111,the output is 12345.11133.
6
2763
by: bananaguyc | last post by:
Okay, I'm running the following code in GCC 4.1.2: <stdio.h> int main(void) { long double test = 4.67e-4; printf("float: %f e-notation: %e\n", test, test); return 0; }
0
8120
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8620
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7047
agi2029
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...
1
6085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4048
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...
0
4115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2560
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
1
1705
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1420
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.