2
So people are having a hard time creating a discount calculator. For example:
I want a number x = 2,27
turn 2.3
and x = 2,24
stay 2.2.
How to do this?
2
So people are having a hard time creating a discount calculator. For example:
I want a number x = 2,27
turn 2.3
and x = 2,24
stay 2.2.
How to do this?
Browser other questions tagged c# function decimal rounding
You are not signed in. Login or sign up in order to post.
This may also be useful: http://answall.com/a/21941/101
– Maniero
A simple way is you create a variable of type
decimal
to receive these values and when presenting them you use the functionToString()
, looks something like this: variable declarationdecimal numero = 0;
attribution of the value to itnumero = 1.33M;
obtaining the rounded value:MessageBox.Show(numero.ToString("N1")); //Resultado: 1,3
, another example:numero = 1.35M;
outworking:MessageBox.Show(numero.ToString("N1")); //Resultado: 1,4
– Joaquim Caetano Teixeira