ACSUtils Wiki

An ACS library for ZDoom-based ports

User Tools

Site Tools


new:rounding

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
new:rounding [2018/02/17 00:15] – created korshunnew:rounding [2018/02/20 16:18] korshun
Line 10: Line 10:
   * ''round'' -- rounds the number to the closest integer   * ''round'' -- rounds the number to the closest integer
  
-Rounding table:+Example rounding table:
  
 ^  x   ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^ ^  x   ^ round(x) ^ floor(x) ^ ceil(x) ^ trunc(x) ^
 ^   1.3|         1|         1|        2|         1| ^   1.3|         1|         1|        2|         1|
-^   1.8|         2|         1|        2|         1| 
 ^   1.5|         2|         1|        2|         1| ^   1.5|         2|         1|        2|         1|
 +^   1.8|         2|         1|        2|         1|
 ^  -1.3|        -1|        -2|       -1|        -1| ^  -1.3|        -1|        -2|       -1|        -1|
-^  -1.8|        -2|        -2|       -1|        -1| 
 ^  -1.5|        -1|        -2|       -1|        -1| ^  -1.5|        -1|        -2|       -1|        -1|
 +^  -1.8|        -2|        -2|       -1|        -1|
  
 Every rounding mode is available as two functions. The ones with the ''i'' prefix in the name return an integer, while the ones without return a fixed-point number: Every rounding mode is available as two functions. The ones with the ''i'' prefix in the name return an integer, while the ones without return a fixed-point number:
Line 27: Line 27:
 ^ round | ''round()'' | ''iround()'' | ^ round | ''round()'' | ''iround()'' |
 ^ trunc | ''trunc()'' | ''itrunc()'' | ^ trunc | ''trunc()'' | ''itrunc()'' |
 +
 +Example of the difference:
 +
 +  * ''floor(2.3) == 2.0;''
 +  * ''ifloor(2.3) == 2;''
  
 So the full function list is as follows: So the full function list is as follows: