c# - Sytem.Double value with max characters -


i'm testing net xml serialization of double[] arrays i'm interested know whats double value has characters int it's serialized can test whats max output size of serialized array.

it should 24.

double.minvalue.tostring("r").length 

from double.tostring(string)

or "r", returns 15 digits if number can represented precision or 17 digits if number can represented maximum precision.

you have there @ max 17 digits, plus 1 sign, plus 1 decimal separator, plus 5 e+xxx (double.maxvalue 1.7976931348623157e+308 , double.epsilon, smallest value > 0, 4.94065645841247e-324, both in form e[+-][0-9]{1,3}).

note technically, in strange languages,

var str2 = double.positiveinfinity.tostring("r"); 

could longer (because string localized), hope you'll serialize numbers cultureinfo.invariantculture!

but remember users have changed culture control panel... like:

var culture = (cultureinfo)cultureinfo.currentculture.clone(); culture.numberformat.negativesign = "negative"; culture.numberformat.numberdecimalseparator = "decimalseparator"; var str4 = double.minvalue.tostring("r", culture); 

result: negative1decimalseparator7976931348623157e+308

for reason it's better use cultureinfo.invariantculture :-)

but if want know truth, in control panel decimal separator can long 3 characters, , negative sign 4 (you can try it, or can check locale_sdecimal , locale_snegativesign, terminating null character can ignored in .net)


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -