473,724 Members | 2,284 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 43448
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
23073
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
3716
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
2307
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
2766
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
8868
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8741
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
9243
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9090
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8063
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...
0
5996
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4504
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...
2
2613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2149
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.