Ignore:
Timestamp:
06/30/20 00:34:59 (2 weeks ago)
Author:
Maciej Komosinski
Message:

Added functions to properly round floating point values to specified precision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/nonstd_math.h

    r913 r970  
    2727inline void rndSetSeed(unsigned int seed) { rndGetInstance().setSeed(seed); }
    2828inline unsigned int rndRandomizeSeed() { return rndGetInstance().randomize(); }
     29
     30
     31
     32// precision==-1 for full precision, or positive values for the number of digits to print past the decimal point.
     33// Allocated buffer with bufferlen=30 is OK.
     34// Returns the number of chars actually used (not including the ending 0).
     35int doubleToString(double x, int precision, char *buffer, int bufferlen);
     36
     37double round(const double x, const int precision);
     38
     39
     40
     41
    2942
    3043//floating point specific numbers
Note: See TracChangeset for help on using the changeset viewer.