|
There are in C#:
-Float
-Double
and
-Decimal.
They are different between their places after the , .
For eg:
Float:
7 Places after the , and numbers from -3,4 * 10^38 to 3,4 * 10^38.
-> That is: Float x = 1.0f /7
x = 0.1428571
Double:
Its 15-16 Places after the , and numbers between 5 * 10^324 to 1,7 * 10^308
-> That is the reason why u use double in most of time.
You can write too : double x = 1.0 / 7
=> X will be 0.14... with 15-16 places.
Decimal is from -7,9*10^28 to 7,9*10^28 and is good for 28-29 places after the , .
-> Decimal x = 1.0m / 7
=> 0.14... 29 places.
Double is good, cause you dont need that difficult Code and it has the highest range..
Hope i could help you, im nativ german, so my english es very very baaaad.
Best regards
To your question: i think its Decimal.
to the Code: You must get 1 Number in form like 5.0m (m for decimal, that everything is in decimal now, and the .0 to get the , and the mathematical right answer)
eg:
decimal x = 10/5
X=0
Decimal x = 10.0m/5
X=2
|