Changeset 1298 for cpp/common
- Timestamp:
- 03/29/24 23:30:34 (11 months ago)
- Location:
- cpp/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_math.cpp
r1280 r1298 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 3Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2024 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include <sstream> 9 9 #include <algorithm> // std::min() 10 #include <common/log.h> 11 12 13 unsigned int rndUint(int limit_exclusive) 14 { 15 if (limit_exclusive < 0) 16 { 17 logPrintf("", "rndUint", LOG_ERROR, "rndUint(negative: %d)", limit_exclusive); 18 return 0; 19 } 20 else return rndUint((unsigned int)limit_exclusive); 21 } 22 10 23 11 24 RandomGenerator &rndGetInstance() … … 125 138 #include <fenv.h> 126 139 140 #ifdef __CYGWIN__ //since my cygwin update in 2024 (g++ (GCC) 11.4.0), these two are no longer found: 141 #define feenableexcept(x) 142 #define fedisableexcept(x) 143 #endif 144 127 145 namespace fpExcept 128 146 { … … 203 221 204 222 #endif 223 -
cpp/common/nonstd_math.h
r1275 r1298 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2024 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 9 9 #ifdef _MSC_VER 10 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 wcze�niej <cmath> bez _USE_MATH_DEFINES, a <cmath> includuje <math.h> (ale tylko raz bo ma "include guards" jak kazdy.h)11 #include <math.h> //in vc2008, <cmath> worked here, but no longer in vc2010 because "something" (some other .h from stl?) earlier includes <cmath> without _USE_MATH_DEFINES, and <cmath> includes <math.h> (just once because it has "include guards" like any other .h) 12 12 #include <float.h> 13 13 //#define isnan(x) _isnan(x) //since 2014 we use std::isnan() 14 14 #define finite(x) _finite(x) 15 #else // m.in. __BORLANDC__15 #else //e.g. __BORLANDC__ 16 16 #include <math.h> 17 17 #endif … … 25 25 inline double rndDouble(double limit_exclusive) { return rndGetInstance().getDouble() * limit_exclusive; } 26 26 inline unsigned int rndUint(unsigned int limit_exclusive) { return (unsigned int)(rndGetInstance().getDouble() * limit_exclusive); } //returns random from 0..limit_exclusive-1 27 inline unsigned int rndUint(size_t limit_exclusive) {return rndUint((unsigned int)limit_exclusive);} //just an overload with size_t argument 28 unsigned int rndUint(int limit_exclusive); //just an overload with int argument 27 29 inline void rndSetSeed(unsigned int seed) { rndGetInstance().setSeed(seed); } 28 30 inline unsigned int rndRandomizeSeed() { return rndGetInstance().randomize(); }
Note: See TracChangeset
for help on using the changeset viewer.