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

Format double to x numbers.

Hi,

I need to find a way to format (round) double to x numbers length.
So .ToString("0.000"); is not good because it has fixed length (in
example 5). I then later parse Double to String, so I can also format
String. But it should not be substring because then the numer is not
correct. (If you just cut the end).

Does anyone know the way to do this?

Sep 6 '06 #1
2 4100
Nobody knows?

What I want is:
let's say

x=4; //max length of number

double a,b,c;
String s;

a=23,45;
b=25,9;

c=607,355;

s=c.ToSting();

display(s);

When I display s I want to be displayed as 607,4 (c rounded to 4
numbers length) or in exponental (but again on 4 places).

Sep 7 '06 #2
Use Math.Round(double, precision)

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

What You Seek Is What You Get.

<bo********@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Nobody knows?

What I want is:
let's say

x=4; //max length of number

double a,b,c;
String s;

a=23,45;
b=25,9;

c=607,355;

s=c.ToSting();

display(s);

When I display s I want to be displayed as 607,4 (c rounded to 4
numbers length) or in exponental (but again on 4 places).

Sep 7 '06 #3

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

Similar topics

11
by: John Lenton | last post by:
Is there any reason python's printf-style formatting is missing the (C99) '%a' specifier? I'm sorry if this has been asked and answered before; I can't find it on google ('%a' is a very awkward...
27
by: geskerrett | last post by:
I am hoping someone can help me solve a bit of a puzzle. We are working on a data file reader and extraction tool for an old MS-DOS accounting system dating back to the mid 80's. In the data...
2
by: geskerrett | last post by:
In the '80's, Microsoft had a proprietary binary structure to handle floating point numbers, In a previous thread, Bengt Richter posted some example code in how to convert these to python floats;...
1
by: Nick | last post by:
Well, the project I am working on has now come to a screeching halt! I have been developing a program that heavily utilizes ADO.NET record sets. To generate reports, I convert the recordset to XML,...
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
3
by: Boz | last post by:
Hi, I am trying to use string.Format() to output the value of a double. double da = 100000000000.99994; double db = 100000000000.9994; double dc = 100000000000.994; double dd =...
4
by: Dennis Myrén | last post by:
Hi. Is there a way to utilize the great primitive data type formatting routines available in .NET without working with strings? I want a byte directly rather than a string. I think it is...
3
by: hharry | last post by:
Hello All, I am using the following to format numbers precise to 2 decimal places with thousand separators: Double number = 100000.87; string MyString = String.Format("{0:0,0.00}", number);...
9
by: Nico VanHaaster | last post by:
Hello, I don't really want to get too much of a debate here, but I have a feeling this just might cause one. I have been trying to increase the performance of one of my applications. (C# .Net...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
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
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,...

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.