473,406 Members | 2,369 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,406 software developers and data experts.

Format display of float variables

Hi,

I have varaiables declared as float, the result of .ToString() is like
1.0000. How can I get rid of the 0s in the decimal? e.g. 1.0000 will be 1
and 1.3500 will be 1.35

TIA
Sep 5 '06 #1
1 1639
Hi John,

1.0000f is displayed as 1, and 1.3500 f is displayed as 1.35 (or rather
1,35 on my computer), using a regular ToString().

You can format the output in a number of ways, but empty zeroes will be
stripped by default, unless you specify them in a format.

Some formatting samples
http://blog.stevex.net/index.php/str...ing-in-csharp/

On Tue, 05 Sep 2006 20:59:24 +0200, John <so*****@microsoft.comwrote:
Hi,

I have varaiables declared as float, the result of .ToString() is like
1.0000. How can I get rid of the 0s in the decimal? e.g. 1.0000 will
be 1
and 1.3500 will be 1.35

TIA



--
Happy Coding!
Morten Wennevik [C# MVP]
Sep 6 '06 #2

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

Similar topics

0
by: Krishan | last post by:
hi, maybe i've been looking at this for too long, but i think i found a strange thing in the JDK. take the color class and use the method getRGB() on a color, you get an integer with the color...
1
by: jt | last post by:
I posted this yesterday, but I am not seeing this out yet: I am having problems with updating a date field in a certain format. The data is stored in an Oracle database. The date is...
6
by: Japhy | last post by:
Hello, I am coding a menu using PHP. Selections on the menu have code like : <li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li> <li> <a...
5
by: google | last post by:
first, a little background... i have a C program which preprocesses some data, and then outputs the results into a text file. that text file, in turn, is used as input to a FORTRAN...
2
by: ruby_bestcoder | last post by:
Hi Im having problem in firefox with display:none/block. I have essentially 3 li elements. In each element there are a few nested div:s. Clicking on one of the divs, makes another div to...
12
by: Rob Meade | last post by:
Hi all, Ok - I've come from a 1.1 background - and previously I've never had any problem with doing this: Response.Write (Session("MyDate").ToString("dd/MM/yyyy")) So, I might get this for...
2
by: Steve Richter | last post by:
I would like to use display:inline and other CSS attributes to build an entry form. Where the heading to the left of the text box is always a set width. It is not working so I am experimenting...
2
by: wreed06 | last post by:
Hello, I have 2 problems. In my webpage, I have a dropdown list with a button that takes the user to a popup window specific to the option. I am using Firefox 2.0.0.13. I have successfully...
4
by: siddhanta | last post by:
float x = new float; float y = new float; int c=0; using (StreamReader sr = new StreamReader("e: \\CuPeak.dat")) { while (!sr.EndOfStream) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.