[Mono-devel-list] Comments for NumberFormatter

Andreas Nahr ClassDevelopment at A-SoftTech.com
Sat Feb 26 17:13:35 EST 2005


I checked through the new NumberFormatter Class and found a few points that 
could perhaps be improved:

* The internal class Numberstore contains things like that at several 
if (v >= 1000000000000000000)
					i = 18;
				else if (v >= 100000000000000000)
					i = 17;
				else if (v >= 10000000000000000)
					i = 16;
I Think it would make sense to revert the order here because a) in real 
world small numbers are more common than large ones. This code is called 
from other functions which deliver e.g. an byte, which surely never can get 
this big.

* NumberFormatter contains several private classes. Some (all?) could likely 
be converted to structs which should help improve performance and reduce 
memory usage.

* There are several places were Strings are used but Chars could be used 
instead (like " ")

* The following line in FormatExponential is really hard to read and should 
be refactored:
return string.Concat ("0", precision > 0 ? "." + new string ('0', precision) 
: "", upper ? "E" : "e", nfi.PositiveSign, "000");

More information about the Mono-devel-list mailing list