Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2004, 03:13 PM
Authorized User
 
Join Date: Apr 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default .ToString() functions cuts off zeros

when converting floats to string how can i prevent the .tostring() function from removing trailing zeros??

rrr
__________________
rrr
 
Old July 6th, 2004, 10:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use a format specifier.

This is C# code. VB.NET is the same - just take out the semicolons.

double d = 123.1;

// For money, use "C":
Console.WriteLine("Value of d: {0}", d.ToString("C"));

// For a fixed 3 decimal places, use "n3":
Console.WriteLine("{0}", d.ToString("n3"));

Eric
 
Old July 6th, 2004, 10:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is a good reference for format options:
http://www.oreilly.com/catalog/cshar...apter/appb.pdf

Eric





Similar Threads
Thread Thread Starter Forum Replies Last Post
Why would you override ToString()? chobo2 C# 2008 aka C# 3.0 16 November 11th, 2008 11:01 PM
image cuts through div Adam H-W CSS Cascading Style Sheets 0 October 13th, 2007 04:10 PM
toString() praveena Java Basics 3 March 20th, 2006 10:52 PM
Request.UrlReferrer.ToString() mike72 BOOK: ASP.NET Website Programming Problem-Design-Solution 2 September 5th, 2005 09:31 AM
right side of page cuts off!need it to scroll? doll deluxe Dreamweaver (all versions) 6 August 28th, 2004 03:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.