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?

1

1 Answer 1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.