mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-03 18:22:22 +00:00
Added rounding macros and constants to math.h
This commit is contained in:
+9
-1
@@ -1,8 +1,16 @@
|
||||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
// Constants
|
||||
#define PI 3.141592653589 // Should be good enough
|
||||
#define E 2.718281828459
|
||||
|
||||
// Macros
|
||||
#define abs(x) ( (x) > 0 ? (x) : -(x) )
|
||||
#define sign(x) ( (x) == 0 ? 0 : ((x) < 0 ? -1 : 1 ) )
|
||||
#define round(x) ( (int)((x) + 0.5) )
|
||||
|
||||
#define floor(x) ( (int)(x) ) // C floors floats when converting to ints
|
||||
#define round(x) ( (int)((x) + 0.5) ) // Normal rounding
|
||||
#define ceil(x) ( (int)((x) + 1) ) // Always rounds up
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user