1

If i console.log this ABDKMath64x64.add(3, 2);

I get the result of BigNumber { value: "5" } which is correct.

But ABDKMath64x64.mul(3, 2); returns BigNumber { value: "0" }

and ABDKMath64x64.div(3, 2); returns BigNumber { value: "27670116110564327424" }

Why i cant get 6 for .mul and 1.5 for div? What am i missing?

damdafayton
  • 113
  • 3

1 Answers1

2

ABDKMath64x64 are math library for fixed-point numbers.

So "3" and "2" are not decimal "3" and "2".

For ABDKMath64x64 first 64bit are integer part and next 64bit are fractional part.

So Integer 3 are 0x00000000000000030000000000000000 for fixed point.

You can try ABDKMath64x64.mul(0x30000000000000000, 0x20000000000000000); returns 0x00000000000000060000000000000000

exd0tpy
  • 36
  • 2