|
| mar11 (29) | |||
Hi all, assuming this code:
How can i declare the variable if i want : 1- to get 90 /20 = 4.5 2- to get 90/20 = 5 thanks for each advance | |||
| bluezor (208) | |
You can declare it as double a; for it to be able to take decimal points.You can round up / round down a value using <cmath>'s two functions - * ceil - http://www.cplusplus.com/reference/clibrary/cmath/ceil/ (rounding up) * floor - http://www.cplusplus.com/reference/clibrary/cmath/floor/ (rounding down) | |
| mar11 (29) | |
| @bluezor: thanks a lot | |
| firedraco (2048) | |
| Also, you need to change either 90 or 20 to a float/double (otherwise you will get 4 because of integer division). | |
Registered users can post in this forum.
