Ignore:
Timestamp:
03/29/24 23:30:34 (13 months ago)
Author:
Maciej Komosinski
Message:

Introduced overloads for rndUint() with size_t and int arguments to avoid numerous type casts in sources

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified cpp/common/nonstd_math.h

    r1275 r1298  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2024  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    99#ifdef _MSC_VER
    1010 #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)
    1212 #include <float.h>
    1313 //#define isnan(x) _isnan(x) //since 2014 we use std::isnan()
    1414 #define finite(x) _finite(x)
    15 #else //m.in. __BORLANDC__
     15#else //e.g. __BORLANDC__
    1616 #include <math.h>
    1717#endif
     
    2525inline double rndDouble(double limit_exclusive) { return rndGetInstance().getDouble() * limit_exclusive; }
    2626inline unsigned int rndUint(unsigned int limit_exclusive) { return (unsigned int)(rndGetInstance().getDouble() * limit_exclusive); } //returns random from 0..limit_exclusive-1
     27inline unsigned int rndUint(size_t limit_exclusive) {return rndUint((unsigned int)limit_exclusive);} //just an overload with size_t argument
     28unsigned int rndUint(int limit_exclusive); //just an overload with int argument
    2729inline void rndSetSeed(unsigned int seed) { rndGetInstance().setSeed(seed); }
    2830inline unsigned int rndRandomizeSeed() { return rndGetInstance().randomize(); }
Note: See TracChangeset for help on using the changeset viewer.