c# - How could I convert a value that looks like a double into an unsigned long, but properly? -


i programming in c# , trying convert string containing value seems double, did first convert string double, typecast double unsigned long. problem unsigned long either few digits greater or few digits lower value suppose receiving. after typecast double unsigned long, convert hexadecimal string , pad it.

here example of doing:

string valuetoparse = "2.53327490880368e+15"; double nvalue1 = double.parse(valuetoparse); ulong nvalue2 = (ulong)nvalue1; string str = nvalue2.tostring("x16"); 

here results of this:

string str = "00090000070ec260"; 

this problem:

right seems if nothing wrong average programmer.
what i'm trying do value being returned real result looking 00090000070ec258 - not - 00090000070ec260 , have no clue may causing difference in values.
assumption can think of may causing value difference typecasting double unsigned long , within process of value being converted, precision of double messing things up.

so please if may know what's going wrong or has ideas may going wrong, please respond. appreciate can provided. thanks. :)

if plug 90000070ec260 programmer's calculator , convert decimal, result of 2533274908803680, corresponds original parsed value.

however, if plug 90000070ec258 in , convert decimal, 2533274908803672, not correspond original parsed value.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -