UINT64 casting for swimming?

Is it possible to include UINT64 in a float? I understand that UINT64 does not contain decimals, so my float will be an integer. However, my delta time return function returns UINT64, which is not very useful for the function that I am currently working with. I assume that simple static_cast <float> (uint64value) will not work?

+3
source share
6 answers

Large UINT64 values โ€‹โ€‹(8 bytes) can be truncated if you pass them to a float, which is only 4 bytes.

+3
source

Define - , 64- , (, - , , ), , , .

+4

long double double:

typedef long double real_type
real_type x = static_cast<real_type>(long1);
real_type y = static_cast<real_type>(long2);

real_type z = x / y;
float result = static_cast<float>(real_type);
+2

: int

, , 16 , , . .

, , IEEE 754, 23 float 52 double. , - , 1FFFFFFFFFFFFF 9007199254740991 .

, 32- double; , .

, , JavaScript . , , " ", .

+1

Safe? ? , IEEE-754 float 23 - (+ 1) . 64- "" 24- , . ? , 64- , - , float, .

0

static_cast?

Max uint64 is 2^64 = 1.84467441 ร— 10^19

this max 32- float

9.999999ร—10^96.

... ?

http://en.wikipedia.org/wiki/Decimal32_floating-point_format

-1

Source: https://habr.com/ru/post/1723057/


All Articles