Nov 29 2012, 01:38 PM
Danger255, post: 81078, member: 14867 Wrote:Please can u explain this further?An integer does not store anything beyond the decimal. That means it always rounds down.
(int)15.9999 = 15
(int)15.4999 = 15
(int)15.5 = 15
(int)15.1 = 15
Real example: 99+99+99+99+98 = 494 / 500 = 0.988 * 100 = 98.8
(int)98.8 = 98
If you intend on rounding to the nearest integer (whole number) then adding 0.5 remedies this situation:
(int)(15.9999 + 0.5) = 16
(int)(15.4999 + 0.5) = 15
(int)(15.5 + 0.5) = 16
(int)(15.1 + 0.5) = 15
Real example: 99+99+99+99+98 = 494 / 500 = 0.988 * 100 = 98.8
(int)(98.8 + 0.5) = 99
Watch out for negative numbers!
Steam Wrote: 4:02 PM - George, of the jungle: was out
4:02 PM - George, of the jungle: bison, dude
4:02 PM - Brawl Bashin’ Bison: ???
4:02 PM - George, of the jungle: you're very rude towards alina
4:02 PM - George, of the jungle: how about unbanning her friend?
4:02 PM - George, of the jungle: I mean
4:02 PM - George, of the jungle: it's only gamebanana skins
4:02 PM - Brawl Bashin’ Bison: LOL
4:02 PM - George, of the jungle: ^^
4:02 PM - Brawl Bashin’ Bison: LOLOL
4:02 PM - George, of the jungle: lol


![[-]](https://war-lords.net/forum/images/collapse.png)