2 #ifndef SYDEVS_SCALE_H_
3 #define SYDEVS_SCALE_H_
182 return level_ == 0 ? 1.0 :
183 level_ < 0 ? 0.001*
scale(level_ + 1).approx() :
184 1000.0*
scale(level_ - 1).approx();
190 return scale(level_);
196 return scale(-level_);
202 return scale(level_ + rhs);
208 return scale(level_ - rhs);
214 return level_ - rhs.level_;
220 return level_ == rhs.level_ ? 1.0 :
221 level_ < rhs.level_ ? 0.001*(
scale(level_ + 1)/rhs) :
222 1000.0*(
scale(level_ - 1)/rhs);
228 return level_ == rhs.level_;
234 return level_ != rhs.level_;
240 return level_ < rhs.level_;
246 return level_ > rhs.level_;
252 return level_ <= rhs.level_;
258 return level_ >= rhs.level_;
268 std::ostream&
operator<<(std::ostream& os,
const scale& rhs);
constexpr bool operator>=(scale rhs) const
Returns true if the scale value is at least rhs.
Definition: scale.h:256
constexpr scale pico
Definition: scale.h:159
arraynd< T, ndims > operator+(const arraynd< T, ndims > &rhs)
Definition: arraynd.h:724
constexpr bool operator<(scale rhs) const
Returns true if the scale value is less than rhs.
Definition: scale.h:238
constexpr scale exa
Definition: scale.h:169
constexpr scale yotta
Definition: scale.h:171
std::ostream & operator<<(std::ostream &os, const arraynd< T, ndims > &rhs)
Definition: arraynd.h:1156
constexpr scale atto
Definition: scale.h:157
constexpr const scale operator+() const
Returns a copy of the scale value.
Definition: scale.h:188
constexpr bool operator<=(scale rhs) const
Returns true if the scale value is at most rhs.
Definition: scale.h:250
scale & operator=(const scale &)=default
Copy assignment.
constexpr scale nano
Definition: scale.h:160
constexpr scale yocto
Definition: scale.h:155
scale & operator++()
Increments (prefix) the level integer.
Definition: scale.cpp:9
constexpr scale no_scale
Definition: scale.h:153
scale & operator--()
Decrements (prefix) the level integer.
Definition: scale.cpp:24
constexpr scale zetta
Definition: scale.h:170
constexpr scale milli
Definition: scale.h:162
constexpr scale peta
Definition: scale.h:168
constexpr bool operator>(scale rhs) const
Returns true if the scale value is greater than rhs.
Definition: scale.h:244
constexpr scale micro
Definition: scale.h:161
constexpr const scale operator-() const
Returns the negation of the scale value.
Definition: scale.h:194
A data type which represents the general concept of scale as a dimensionless power of 1000...
Definition: scale.h:70
constexpr int64 level() const
Returns the level integer.
Definition: scale.h:174
int8 level_type
The type used to store the "level" integer internally.
Definition: scale.h:73
char symbol() const
Provdes the metric prefix symbol.
Definition: scale.cpp:53
scale & operator+=(int64 rhs)
Adds rhs to the level integer.
Definition: scale.cpp:39
constexpr scale tera
Definition: scale.h:167
constexpr scale zepto
Definition: scale.h:156
constexpr bool operator==(scale rhs) const
Returns true if the scale value equals rhs.
Definition: scale.h:226
constexpr float64 operator/(scale rhs) const
Returns 1000 to the power of level() divided by 1000 to the power of rhs.level(). ...
Definition: scale.h:218
constexpr scale giga
Definition: scale.h:166
scale & operator-=(int64 rhs)
Subtracts rhs from the level integer.
Definition: scale.cpp:46
constexpr scale kilo
Definition: scale.h:164
constexpr bool operator!=(scale rhs) const
Returns true if the scale value does not equal rhs.
Definition: scale.h:232
~scale()=default
Destructor.
constexpr scale unit
Definition: scale.h:163
int64_t int64
Definition: number_types.h:14
int8_t int8
Definition: number_types.h:11
constexpr float64 approx() const
Returns 1000 to the power of level(), rounded if necessary.
Definition: scale.h:180
double float64
Definition: number_types.h:22
constexpr scale femto
Definition: scale.h:158
constexpr scale mega
Definition: scale.h:165
constexpr scale()
Constructs a scale value with a level integer of zero.
Definition: scale.h:141