23 #ifndef ELEMENTSKERNEL__IMPL_STORAGE_ICPP_
24 #define ELEMENTSKERNEL__IMPL_STORAGE_ICPP_
37 return std::round(value * static_cast<T>(factor))/
static_cast<T
>(factor);
40 template<std::
size_t max_digits,
typename T>
45 T converted_value = size;
47 if (source_unit != target_unit) {
49 int64_t target_factor = StorageFactor[target_unit];
50 double value =
roundToDigits(static_cast<double>(size_in_bytes)/static_cast<double>(target_factor),
52 converted_value = Elements::numberCast<T>(value);
55 return converted_value;
64 T converted_value = size;
66 if (source_unit != target_unit) {
68 int64_t target_factor = StorageFactor[target_unit];
69 double value =
roundToDigits(static_cast<double>(size_in_bytes)/static_cast<double>(target_factor),
70 static_cast<size_t>(log10(static_cast<double>(target_factor))));
71 converted_value = Elements::numberCast<T>(value);
74 return converted_value;
82 #endif // ELEMENTSKERNEL__IMPL_STORAGE_ICPP_
Casting with the correct (closest) rounding.
ELEMENTS_API T roundToDigits(const T &value, const size_t &max_digits)
#define ELEMENTS_API
Dummy definitions for the backward compatibility mode.
ELEMENTS_API T storageConvert(const T &size, StorageType source_unit, StorageType target_unit)
ELEMENTS_API std::map< StorageType, std::int64_t > StorageFactor