Returning unanticipated results #154
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @its-me-ilia, thank you for your question. I am sorry that you didn't find the current state of the docs satisfactory - there are a few examples offered in the README. Might you have missed them? ud(15).mul(ud(2))
Now, what you are perhaps interested in is the ud(15e18).mul(ud(2e18)); If you would like to pass a sub-unitary value, you would do this: ud(0.5e18); // this is 0.5 I know that the DX isn't great, but this is a present inherent limitation of Solidity. It is not currently possible to multiply fixed-point literals, so you always have to pass the Any feedback on how I could improve the docs/ README would be welcome! |
Beta Was this translation helpful? Give feedback.
Hi @its-me-ilia, thank you for your question. I am sorry that you didn't find the current state of the docs satisfactory - there are a few examples offered in the README. Might you have missed them?
UD60x18
is a fixed-point type with 18 decimals, which means that the values you passed here are actually0.000000000000000015
and0.000000000000000002
. These numbers are so small that when multiplied together, they yield a number with more than 18 zeroes after the dot, therefore PRBMath gives you the result0
.Now, what you are perhaps interested in is the
toUD60x18
conversion function, which would do the conversion from15
to15e18
. Personally, I do not use that method becau…