## 6 replies

Last post Jul 02, 2012 12:17 PM by mshoaiblibra

0 Points

5 Posts

### Decimal places problem

Hello guys i hope that you can help me in my problem, I'm creating a sceintific application and using decimal in my database and in some cases i have to make it up to 6 digits places and when it displayed in the form it becomes so ugly and i got something like that 125.000000 and the end user dont like it so is there is any way that i can keep the 6 places and in the display whether in the form or in a grid or in a crystal report if there is nothing after the decimal it becomes 125 and if there is any thing after the decimal it appears

plz help me guys

Contributor

2208 Points

445 Posts

### Re: Decimal places problem

Hi,

You can keep the decimal and output the format like so: -

```String.Format("{0:0,0.0}", 12345.67);     // "12,345.7"
String.Format("{0:0,0}", 12345.67);       // "12,346"```

HTH's

Regards,
BoogleC

Please mark the right solution as the answer. This helps others find what they're looking for.

Star

12109 Points

1818 Posts

### Re: Decimal places problem

in c#

```String.Format("{0:0,0.##}", 12345.67); // 12,345.67
String.Format("{0:0,0.##}", 12345.6); // 12,345.6
String.Format("{0:0,0.##}", 12345); // 12,345```

• Edited by urenjoy on Jul 02, 2012 10:44 AM
• Edited by urenjoy on Jul 02, 2012 10:58 AM

All-Star

15346 Points

3142 Posts

Participant

1637 Points

265 Posts

### Re: Decimal places problem

You must be use:

`String.Format("{0:0.######}", 125.000000);Hope so. You'll get solution. :)`
Please mark the replies as answers if they help or unmark if not.

M Shoaib Waheed
MCPD [ASP 4.0]

0 Points

5 Posts

### Re: Decimal places problem

thnx guys but i dont want to round the numbers i want to display it as i got it from the sheets for example in some cases the quantity looks like this 1.200 and in another row it looks like this 0.154315 so i had to make it decimal(18,6) and as aresult the first row will look like 1.200000 and that is a big problem so i need to keep it with 6 decimal places and in the display if there is zeroos after the dicemal so it could be skipped and the user can accept it if it looks like 1.2 but not 1.200000

any help plz

• Edited by Hitman47 on Jul 02, 2012 11:04 AM

Participant

1637 Points

265 Posts

### Re: Decimal places problem

`String.Format("{0:0.######}", 1.2000000);it is working fine. I have tested it.`