I want with a given double number to return its “size” (known as |number|, or number of digit without the numbers after the dot), for example:
12.324654 -> 2
12 -> 2
0.99 -> 0
1.01 -> 1
901 -> 3
-0.99 -> 0
-9.999 -> 1
There must be a function is .net that I dont familiar with that does it..
Thanks.
Math.Abswill convert to positive number (don’t want to count the negative sign)(int)will drop the digits following the decimal pointToString()converts to a string ===> “12”Lengthtells you how many characters there arethere is an edge case where
(int)( some number ) == 0, where the length is going to give you 1– you may not want this, so be aware of the possibilitynow, what you COULD do is make this an extention method….