whupdup
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 122 |
|
|
| 09 Nov 2013 08:53 PM |
Cause I sure do. Le integer casting function:
function int(num) local inum,idec = math.modf(num) if idec >= 0.5 then return inum + 1; else return inum; end end |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2013 08:57 PM |
function int(n) return math[(n % 1 >= 0.5 and 'ceil' or 'floor')](n) end
There. |
|
|
| Report Abuse |
|
|
|
| 09 Nov 2013 09:08 PM |
What, would you rather use integers when you should use decimals? Would you rather hack together every floating-point value as DWORD (32 bits. Who needs size_t anyway? Micro$oft $upremacy. //:■( ) because your language doesn't support floats? Also, you don't need to round. You should probably just go math.ceil(). |
|
|
| Report Abuse |
|
|
whupdup
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 122 |
|
|
| 09 Nov 2013 09:20 PM |
| But when you output numbers like angles and it gives you like 27.55675665435645 so eat my shorts. |
|
|
| Report Abuse |
|
|
whupdup
|
  |
| Joined: 18 Aug 2012 |
| Total Posts: 122 |
|
|
| 09 Nov 2013 09:36 PM |
Heh, get it? Shorts? Whatever.
Anyway, float your floating-points over somewhere else. |
|
|
| Report Abuse |
|
|
XAXA
|
  |
| Joined: 10 Aug 2008 |
| Total Posts: 6315 |
|
|
| 10 Nov 2013 03:00 AM |
I like decimals.
Don't discriminate. |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2013 03:25 AM |
| whatever floats your float. |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 10 Nov 2013 12:08 PM |
"function int(n) return math[(n % 1 >= 0.5 and 'ceil' or 'floor')](n) end"
Ugly.
function int(n) return math.floor(n+0.5) end |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
| |
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
| |
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
| |
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 10 Nov 2013 12:54 PM |
| oysi: good point, but doesn't % call math.fmod() internally, therefore making your method slower than mine? |
|
|
| Report Abuse |
|
|
|
| 10 Nov 2013 02:02 PM |
@digpoe,
.....u would have to see what math.floor does before you can assume that.
but anyhow who cares its probably only a few microseconds difference |
|
|
| Report Abuse |
|
|
Cryptize
|
  |
| Joined: 01 Oct 2010 |
| Total Posts: 949 |
|
|
| 10 Nov 2013 02:26 PM |
| Decimals give me the power to break things up more precisely... So no I like decimals. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Nov 2013 02:31 PM |
Decimals are w/e, unless it's like 5.000000000000001 stupid flooats |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2013 08:08 AM |
-sigh- no offense to the others, but that's not integer casting, that's rounding. Integer casting is getting the floor.
EOS db 0x00 ;End of String Marker |
|
|
| Report Abuse |
|
|
|
| 14 Nov 2013 06:38 PM |
>whatever floats your float. Actually, whatever ints your float. |
|
|
| Report Abuse |
|
|