1 | #ifndef _NONSTD_MATH_H_ |
---|
2 | #define _NONSTD_MATH_H_ |
---|
3 | |
---|
4 | |
---|
5 | #ifdef _MSC_VER |
---|
6 | #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define M_PI etc. |
---|
7 | #include <math.h> //w vc2008 dzia³a³o tu <cmath>, ale w vc2010 juz nie bo "co" (jaki inny .h stl'a?) includuje wczeniej <cmath> bez _USE_MATH_DEFINES, a <cmath> includuje <math.h> (ale tylko raz bo ma "include guards" jak kazdy .h) |
---|
8 | #include <float.h> |
---|
9 | #define isnan(x) _isnan(x) |
---|
10 | #define finite(x) _finite(x) |
---|
11 | #else //m.in. __BORLANDC__ |
---|
12 | #include <math.h> |
---|
13 | #endif |
---|
14 | |
---|
15 | #ifdef _WIN32 //http://stackoverflow.com/questions/2170385/c-math-functions |
---|
16 | double round(double val); |
---|
17 | #endif |
---|
18 | |
---|
19 | |
---|
20 | //random number generator: |
---|
21 | #include "random.h" |
---|
22 | RandomGenerator& rndGetInstance(); |
---|
23 | |
---|
24 | #define rnd01 (rndGetInstance().getDouble()) |
---|
25 | #define rnd0N(limit) (rndGetInstance().getDouble()*(limit)) |
---|
26 | #define randomN(limit) ((unsigned int)(rndGetInstance().getDouble()*(limit))) |
---|
27 | #define setRandomSeed(seed) rndGetInstance().setSeed(seed) |
---|
28 | #define setRandomRandomSeed() rndGetInstance().randomize() |
---|
29 | |
---|
30 | //floating point specific numbers |
---|
31 | #include "stdlib.h" |
---|
32 | |
---|
33 | #ifdef __BORLANDC__ |
---|
34 | #include <float.h> |
---|
35 | #define isnan(x) _isnan(x) //http://stackoverflow.com/questions/570669/checking-if-a-double-or-float-is-nan-in-c |
---|
36 | #define finite(x) _finite(x) |
---|
37 | #endif |
---|
38 | |
---|
39 | #ifdef IPHONE |
---|
40 | #define finite(x) (!isinf(x)) |
---|
41 | #endif |
---|
42 | |
---|
43 | |
---|
44 | #if defined SHP && !defined TIZEN |
---|
45 | //#define __assert_func(a,b,c,d) 0 //Currently, we are sorry to inform you that assert() is not yet supported. We have considered your request for internal discussion. Na szczêcie jest w³asna (byle by by³a, bo i tak zak³adamy ze assert ktore przeciez dziala tylko w trybie debug nie jest potrzebne na bada) implementacja w "bada-assert.cpp" |
---|
46 | #define isnan(x) false //isnan() sie nie linkuje |
---|
47 | #define finite(x) true //j.w. |
---|
48 | //#include <cstdlib> //RAND_MAX defined incorrectly |
---|
49 | //#ifdef BADA_SIMULATOR //...but only in simulator libs |
---|
50 | // #undef RAND_MAX |
---|
51 | // #define RAND_MAX 32768 //...this is the actual value used by rand() |
---|
52 | //#endif |
---|
53 | #endif |
---|
54 | |
---|
55 | |
---|
56 | //handling floating point exceptions |
---|
57 | void fpExceptInit(); //call once, before ...Enable/Disable |
---|
58 | void fpExceptEnable(); |
---|
59 | void fpExceptDisable(); |
---|
60 | |
---|
61 | #endif |
---|
62 | |
---|