Hello. I am new in solitidity. Tip me please how to work with decimal numbers in contracts.

Nov 2, 2021, 2:22 PM
What way do you use in your work?
Nov 2, 2021, 2:22 PM
Calculate floting point numbers
Im looking for someone with experience in web3 implementations for a quick assesment hahaha i feel so stuck rn, im paying of course
Nov 2, 2021, 2:52 PM
Do you know good library for that? Floating points are not fully supports in Solidity for now.
Nov 2, 2021, 2:54 PM
Thats why u use the decimals
if i have 10.80 for example and the decimals in your token are 9 you can calculate it like 10800000000
Nov 2, 2021, 2:55 PM
I am creating a swap and I need accuracy in my calculations
Yes, I know it, but when I need to divide numbers I can get decimal values.
Nov 2, 2021, 2:56 PM
You can, divide the amount /10**decimals
Nov 2, 2021, 2:57 PM
Do you mean that I will receive lower divide mistake in such case?
Nov 2, 2021, 2:58 PM
You need to know the decimals of whatever you are swapping before hand, you can pull that from the decimals constant of the contract if its public or the decimals public view in the contract
Then you can have precision
Nov 2, 2021, 3:00 PM
Okay. Thank you. I will back soon with other questions on this topic😂
Nov 2, 2021, 3:07 PM
When you deploy those kind of tokens theres 2 deployemnts, 1 for an itterable mapping and 1 for the actual contract, you need to provide the address of the iterable mapping as well
No check your txs and you will see 2 deployments
Nov 2, 2021, 3:52 PM

© 2024 Draquery.com All rights reserved.