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

formatting of doubles

Hi,

Is there a format string that can be passed into the the ToString method of
a double datatype that will not show the decimal place if the number is a
whole number, but show up to n decimal places if it isn't?
E.g. If I have variables of type double with the values of 1, 1.15, and 1.5
I would like the ToString call to return respectively "1", "1.15", and
"1.50" using the same format string for each. Is this possible?

Thanks!
Nov 21 '05 #1
0 604

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

Similar topics

7
by: Rob Meade | last post by:
Hi all, I have a recordset iterating through and dumping out to the screen a series of percentages, using the precision 5 and numericscale 2 etc. When I dump them to the page some of the...
1
by: wongjoekmeu | last post by:
Hello All, I have a following piece of code in C that I need to rewrite to C++. However I just don't seem to be able to understand the format rules in C. The C code look like this: I have...
2
by: Ingo Nolden | last post by:
Hello, I want to format floats ( doubles ) into small strings of 7 characters. I tried to use std::ostream, but I don't get the desired behaviour. Especially in scientific notation I am not...
2
by: Homer Simpson | last post by:
Hi, I'm looking for a way to format the output of my double value. For example, the result of a calculation may be 12.3456789 but I want to display 12.346 (three decimal places of precision)....
5
by: Tales Normando | last post by:
The title says it all. Anyone?
12
by: John Smith | last post by:
This code for the comparison of fp types is taken from the C FAQ. Any problems using it in a macro? /* compare 2 doubles for equality */ #define DBL_ISEQUAL(a,b)...
7
by: Ryan | last post by:
I have a DataGridView which displays numeric (Int32) data from an underlying database. I want the numbers to be displayed in numeric format "#,###" (with commas). I want to also limit the user so...
27
by: brad | last post by:
Does anyone else feel that unittesting is too much work? Not in general, just the official unittest module for small to medium sized projects? It seems easier to write some quick methods that are...
5
by: =?Utf-8?B?TWFuanJlZSBHYXJn?= | last post by:
Hi, I developed a custom Matrix class derived from custom VC++ doubles Array class derived from a RealArray which is defined as: typedef CArray<double,doubleRealArray; Now I need to convert...
2
by: utab | last post by:
Dear all, On a formatted printing operation that I am trying to accomplish for doubles, I have a question. I would like to print a double, d, and its square, d*d, but I would like to make the...
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...
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.