BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
|
Macros for rounded integer division and percent. More...
Go to the source code of this file.
Macros | |
#define | IDIV_ROUND(X, Y) (((X)+(Y)/2)/(Y)) |
#define | IDIV_CEILING(X, Y) (((X)+(Y)-1)/(Y)) |
#define | IDIV_WHOLE(X, Y) ((((X)*10+(Y)/2)/(Y))/10) |
#define | IDIV_TENTH(X, Y) (((((X)-IDIV_WHOLE((X),(Y))*(Y)) * 10 + (Y)/2)) / (Y)) |
#define | IDIV_PERCENT(X, Y) (((X)*100+((Y)/2))/(Y)) |
Macros for rounded integer division and percent.
#define IDIV_CEILING | ( | X, | |
Y | |||
) | (((X)+(Y)-1)/(Y)) |
Integer division, round up.
Note that this works only for non-negative numbers.
#define IDIV_PERCENT | ( | X, | |
Y | |||
) | (((X)*100+((Y)/2))/(Y)) |
Compute Percentage, round result.
#define IDIV_ROUND | ( | X, | |
Y | |||
) | (((X)+(Y)/2)/(Y)) |
Integer division, round result
Note that this works only for non-negative numbers.
#define IDIV_TENTH | ( | X, | |
Y | |||
) | (((((X)-IDIV_WHOLE((X),(Y))*(Y)) * 10 + (Y)/2)) / (Y)) |
Integer division with one decimal place, tenth.
Note that this works only for non-negative numbers.
#define IDIV_WHOLE | ( | X, | |
Y | |||
) | ((((X)*10+(Y)/2)/(Y))/10) |
Integer division with one decimal place, whole part.
Note that this works only for non-negative numbers.