Common functions to work with integers and doubles. More...
#include <string>
#include <cstdint>
Namespaces | |
Lox | |
Common methods and functionality easily shared between projects. | |
Lox::Numbers | |
Common functions to work with integers and doubles. | |
Functions | |
std::string | Lox::Numbers::approximateSize (const uint64_t bytes) |
Returns a simple easy-to-read text string representing the number of bytes. More... | |
std::string | Lox::Numbers::format (const double &d) |
Format a double into a simple string. Will truncate trailing zeros. More... | |
std::string | Lox::Numbers::format (const double &d, const int decimals) |
Format a double into a simple string. Will truncate, pad, or round as necessary to the specified number of decimal places. More... | |
std::string | Lox::Numbers::format (const int &i) |
Format an integer into a simple string. More... | |
bool | Lox::Numbers::nearlyTheSame (const double a, const double b) |
Determine if the two values are nearly the same. More... | |
bool | Lox::Numbers::parse (const std::string &str, double &d, double &fraction) |
Parse a text string and get back the numeric value as a double. More... | |
bool | Lox::Numbers::parse (const std::string &str, double &d) |
Parse a text string and get back the value as a double. More... | |
bool | Lox::Numbers::parse (const std::string &str, int &i) |
Parse a text string and get back the value as an integer. This will round (not truncate) fractional values. More... | |
int | Lox::Numbers::random (const int minimum, const int maximum) |
Generate a random number. More... | |
int | Lox::Numbers::random (const int maximum) |
Similar to random( const int, const int ), but the minimum is set to zero. More... | |
double | Lox::Numbers::random (const double minimum, const double maximum=1.0) |
Generate a random number. More... | |
std::string | Lox::Numbers::reformatDoubleStr (const std::string &str) |
If the input string is a valid double, reformat the string. Make no change if the string is not a valid double. More... | |
std::string | Lox::Numbers::reformatIntegerStr (const std::string &str) |
If the input string is a valid integer, reformat the string. Make no change if the string is not a valid integer. More... | |
std::string | Lox::Numbers::reformatStr (const std::string &str) |
If the input string is a valid number, reformat the string. More... | |
bool | Lox::Numbers::validate (const std::string &str) |
Determine if the text is a valid number. Assumes "double". More... | |
bool | Lox::Numbers::validateDouble (const std::string &str) |
Determine if the text is a valid double. More... | |
bool | Lox::Numbers::validateInteger (const std::string &str) |
Determine if the text is a valid integer. More... | |
double | Lox::Numbers::round_to_2_decimals (double value) |
Round to 2 decimal places. More... | |
long double | Lox::Numbers::round_to_2_decimals (long double value) |
Round to 2 decimal places. More... | |
Common functions to work with integers and doubles.