Program Listing for File utility.cpp¶
↰ Return to documentation for file (src/utility.cpp
)
#include "utility.h"
namespace PixelMaestro {
// Must initialize static char value in source file.
int32_t Utility::seed_ = 1;
uint32_t Utility::abs_int(int32_t val) {
return val > 0 ? val : -val;
}
int32_t Utility::rand(int32_t max) {
seed_ = (seed_ * 1103515245U + 12345U) & 0x7fffffffU;
if (max == 0) {
return (int32_t)seed_;
}
else {
return (int32_t)seed_ % max;
}
}
void Utility::srand(int32_t seed) {
seed_ = seed;
}
}