Click here to Skip to main content
13,558,655 members
Rate this:
Please Sign up or sign in to vote.
See more:
a double number has tihs value: 219.67377380133897

I've tried to change it to string using format strings:

number.ToString("###0.0###############") = 251.673773801339 > (897) changed by 9
number.Tostring("F16") = 219.673773801339000 > (897) changed by 9

Any way to solve this??
Posted 26-Feb-13 3:54am
‭011111100010‬ 26-Feb-13 9:59am
Have you tried just .ToString()?
faneleo 26-Feb-13 10:18am
.ToString() doesn't work on all situations, until now this is the only problem I have using string formats.
Sergey Alexandrovich Kryukov 26-Feb-13 14:57pm
Where do you think ToString(string) won't work?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

A Double value has up to 15 decimal digits of precision, although a maximum of 17 digits is maintained internally, Double structure[^].

As you have found out, many of the format specifiers will only access 15 digits. To see all 17 use the round trip specifier "R" or the general specifier "G17".

faneleo 26-Feb-13 10:48am
Thanks, it resolved my issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01-2016 | 2.8.180515.1 | Last Updated 26 Feb 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100