how do you convert any value int, double, float and so on into a decimal with only .0 decimal place
example
height 155.55
height2 213.5
height3 444.0
average height = 271.0166666666=(height+2+3)/3
but i want to display only 271.0
Printable View
how do you convert any value int, double, float and so on into a decimal with only .0 decimal place
example
height 155.55
height2 213.5
height3 444.0
average height = 271.0166666666=(height+2+3)/3
but i want to display only 271.0
There is a Round method in the Decimal structure (but you would not find any equivalent method for double types) . It rounds the decimal variable to the specified number of decimal places. For examples and more detail see here. Hope this helps. :thumb:
Don't forget to rate good/helpful posts. :thumb:
other wise, use the string's format method to acquire the correct effect.
i see thanks to both
You can display any number as a string with exactly 1 decimal place by calling ToString("n1"). This will display 1 decimal place even if the number is a round integer. It will also perform standard rounding on the second decimal place. It further has the advantage of affecting display only and not the actual numerical value of the variable.