473,322 Members | 1,522 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,322 software developers and data experts.

Printing double with no trailing zeros

Hello,

what printf statement do I use to get variable that is double to print
123.456 not 123.456000

Thanks,
Michael
Nov 13 '05 #1
3 27838

Hi Michael,

"Michael" <IN******@aol.com> schrieb im Newsbeitrag
news:fP*********************@twister.tampabay.rr.c om...
what printf statement do I use to get variable that is double to print
123.456 not 123.456000


"%g" :-)

I hope that helps.

Regards,
Ekkehard Morgenstern.
Nov 13 '05 #2
Yes, that did it.
Thanks,
Michael

"Ekkehard Morgenstern" <ek******************@onlinehome.de> wrote in message
news:bp**********@online.de...

Hi Michael,

"Michael" <IN******@aol.com> schrieb im Newsbeitrag
news:fP*********************@twister.tampabay.rr.c om...
what printf statement do I use to get variable that is double to print
123.456 not 123.456000


"%g" :-)

I hope that helps.

Regards,
Ekkehard Morgenstern.

Nov 13 '05 #3
Michael wrote:
Hello,

what printf statement do I use to get variable that is double to print
123.456 not 123.456000


#include <stdio.h>

int main(void)
{
double x = 123.456;
printf("%.3f\n", x);
return 0;
}

[output]
123.456
--
Martin Ambuhl

Nov 13 '05 #4

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

Similar topics

29
by: mrstephengross | last post by:
Hi all... How can I find out the number of significant digits (to the right of the decimal place, that is) in a double? At least, I *think* that's what I'm asking for. For instance: 0.103 --> 3...
5
by: Jason | last post by:
I have a column defined as DECIMAL(10,6). I want to display it as a string but I do not want the trailing zeros. I cannot seem to get CAST or CONVERT or STR to exclude the zeros. Examples:...
6
by: J | last post by:
Would anyone know if there a type tag to format a double? I have f for floating point, but cannot find one for double.
3
by: V. Jenks | last post by:
I need to store money values in C# and I noticed when using a float, the trailing zero was trimmed off automatically. I don't want this, is there a native type that will *not* do this so I can...
15
by: Bob | last post by:
I'm about to convert to string and use regex, but I thought there must be something I'm missing here that already exists. Bob
3
by: H.B. | last post by:
Hi, How can I split Double into two integers like the following example : 2.34 -> 2 and 34 (I dont want the modf() result that gives 2 and 0.34) Hugo
9
by: Chester | last post by:
I'm working on an app that records data collected by service technicians (VB.Net front-end, SQL Server 2000 back end). The technicians need to record numbers with varying scale and precision. For...
7
by: Angus | last post by:
I am writing a class which represents a byte array - ie an array of unsigned char. So far I have worked out how to add strings, integers, WORD's, etc. But how would I add a double? Would I...
7
by: Ouroborus777 | last post by:
I've been messing around with printing floats. It seems that printf() is only capable of printing the fractional portion at a fixed length. Is there some way to print floats such that the full...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.