-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmath.hpp
More file actions
52 lines (39 loc) · 921 Bytes
/
math.hpp
File metadata and controls
52 lines (39 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef __MATH_HPP
#define __MATH_HPP
#include "builtin.hpp"
#include <cmath>
#include <float.h>
#ifdef isfinite
#undef isfinite
#endif
#ifdef isinf
#undef isinf
#endif
#ifdef isnan
#undef isnan
#endif
namespace __math__ {
using namespace __shedskin__;
extern str* __name__;
const __ss_float pi = 3.14159265358979323846;
const __ss_float e = 2.71828182845904523536;
class ValueError {
public:
str* message;
ValueError(str* msg) : message(msg) {}
};
// Custom implementation without std::isfinite
inline __ss_bool isfinite(__ss_float x) {
return x == x && x != INFINITY && x != -INFINITY;
}
inline __ss_bool isnan(__ss_float x) {
return x != x;
}
inline __ss_bool isinf(__ss_float x) {
return x == INFINITY || x == -INFINITY;
}
void __init() {
__name__ = new str("math");
}
}
#endif // __MATH_HPP