1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
3 | // See LICENSE.txt for details. |
---|
4 | |
---|
5 | #ifndef _NONSTD_MATH_H_ |
---|
6 | #define _NONSTD_MATH_H_ |
---|
7 | |
---|
8 | |
---|
9 | #ifdef _MSC_VER |
---|
10 | #define _USE_MATH_DEFINES //after this is defined, the next #include <math.h> or <cmath> will define M_PI etc. |
---|
11 | #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) |
---|
12 | #include <float.h> |
---|
13 | //#define isnan(x) _isnan(x) //since 2014 we use std::isnan() |
---|
14 | #define finite(x) _finite(x) |
---|
15 | #else //m.in. __BORLANDC__ |
---|
16 | #include <math.h> |
---|
17 | #endif |
---|
18 | |
---|
19 | #if (defined __BORLANDC__ || (_MSC_VER <= 1700)) & (!defined EMSCRIPTEN) |
---|
20 | double round(double val); //http://stackoverflow.com/questions/2170385/c-math-functions |
---|
21 | #endif |
---|
22 | |
---|
23 | |
---|
24 | //random number generator: |
---|
25 | #include "random.h" |
---|
26 | RandomGenerator& rndGetInstance(); |
---|
27 | |
---|
28 | #define rnd01 (rndGetInstance().getDouble()) |
---|
29 | #define rnd0N(limit) (rndGetInstance().getDouble()*(limit)) |
---|
30 | #define randomN(limit) ((unsigned int)(rndGetInstance().getDouble()*(limit))) |
---|
31 | #define setRandomSeed(seed) rndGetInstance().setSeed(seed) |
---|
32 | #define setRandomRandomSeed() rndGetInstance().randomize() |
---|
33 | |
---|
34 | |
---|
35 | //floating point specific numbers |
---|
36 | #include "stdlib.h" |
---|
37 | |
---|
38 | #ifdef __BORLANDC__ |
---|
39 | #include <float.h> |
---|
40 | #define isnan(x) _isnan(x) //http://stackoverflow.com/questions/570669/checking-if-a-double-or-float-is-nan-in-c |
---|
41 | #define finite(x) _finite(x) |
---|
42 | #endif |
---|
43 | |
---|
44 | #ifdef LINUX |
---|
45 | #define _isnan(a) isnan(a) |
---|
46 | #endif |
---|
47 | |
---|
48 | #ifdef IPHONE |
---|
49 | #define finite(x) (!isinf(x)) |
---|
50 | #define _isnan(a) isnan(a) |
---|
51 | #endif |
---|
52 | |
---|
53 | |
---|
54 | #if defined SHP |
---|
55 | //#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" |
---|
56 | #define isnan(x) false //isnan() sie nie linkuje |
---|
57 | #define finite(x) true //j.w. |
---|
58 | //#include <cstdlib> //RAND_MAX defined incorrectly |
---|
59 | //#ifdef BADA_SIMULATOR //...but only in simulator libs |
---|
60 | // #undef RAND_MAX |
---|
61 | // #define RAND_MAX 32768 //...this is the actual value used by rand() |
---|
62 | //#endif |
---|
63 | #endif |
---|
64 | |
---|
65 | |
---|
66 | //handling floating point exceptions |
---|
67 | void fpExceptInit(); //call once, before ...Enable/Disable |
---|
68 | void fpExceptEnable(); |
---|
69 | void fpExceptDisable(); |
---|
70 | |
---|
71 | #endif |
---|