{
nvme_uint128_t u;
nvme_uint128_t tmp;
+
memcpy(tmp.bytes, data, 16);
u.words[0] = le32_to_cpu(tmp.words[3]);
u.words[1] = le32_to_cpu(tmp.words[2]);
long double int128_to_double(__u8 *data)
{
- int i;
long double result = 0;
+ int i;
for (i = 0; i < 16; i++) {
result *= 256;
static long double uint128_t_to_double(nvme_uint128_t data)
{
- int i;
long double result = 0;
+ int i;
for (i = 0; i < sizeof(data.words) / sizeof(*data.words); i++) {
result *= 4294967296;
char *uint128_t_to_si_string(nvme_uint128_t val, __u32 bytes_per_unit)
{
- static char str[40];
long double bytes = uint128_t_to_double(val) * bytes_per_unit;
+ static char str[40];
const char *suffix = suffix_si_get_ld(&bytes);
int n = snprintf(str, sizeof(str), "%.2Lf %sB", bytes, suffix);