math - How to store three small numbers into one double? -
i have int a, b, c
. , a
in range 0-9999
, b
0-99
, c
0-99
.
because function must return 1 double
, think of putting them 1 number. otherwise need call function 3 times. cannot write efficient code this. called millions times, should quite effective, no asm.
i need function double pack3int_to_double(int a, int b, int c) {}
couldn't store + 1000b + 100000c?
for example, if wanted store = 1234, b = 6, , c = 89, you'd store
89061234 ccbaaaa
you can extract numbers casting double int
, using standard integer division , modulus tricks recover individual values.
hope helps!
Comments
Post a Comment