# Questions tagged [decimals]

The tag has no usage guidance.

10 questions
Filter by
Sorted by
Tagged with
93 views
+50

### price conversion using chainlink ETHUSD price

I'm storing a product's USD value in contract. mapping (string => uint256) productUSD; For example, if it's \$52 I'd store it as productUSD[_product] = 52; Now, when people paying in ETH, I want to ...
55 views

### How can I multiply a fixed decimal var by a uint in solidity?

In base to this example: Dealing with multiplying fractions in solidity I am adding th DSMath correctly. I can operate and compile with integers but if I try to compile a contract with any decimal ...
43 views

### Division and floor rounding with 18 decimals

I am recreating a UNISWAP-like AMM and have encountered problems anytime I want to divide the balances of tokens in my pool. For example: I want to require() that tokens are deposited in the correct ...
29 views

### I want to store decimal value in a storage variable and later use that variable at same precision in the formula later internally

I want to store uint public MINTING_VELOCITY = 0.000002; And later use it in the formula: A x t x MINTING_VELOCITY ,where A = 2000 ,t(staking_duration_time) = 120 Issue is currently MINTING_VELOCITY ...
17 views

### Vyper binary fixed point vs Decimal fixed point

there is something i do not understand in Vyper documentation: https://vyper.readthedocs.io/en/stable/index.html Binary fixed point: Decimal fixed point is better, because any decimal fixed point ...
233 views

### ERC20 Token convert unit256 format depending on decimal

Hello i am trying to convert unit256 format depending on the decimal value of each token address. Decimal 9 and 18 ı did converted. they work fine as seen in the code below but I don't know what to do ...
44 views

### Why do almost all of the ERC20 tokens have even number of decimals?

I'm thinking of creating a token with a decimal point of odd number. However I'm kind of worried if there is any issue that can be caused by using an odd number for the decimal point. Is there any ...
49 views

### How to calculate the right amount of a token to use in 0x quote endpoint

I'm trying to use 0x to buy tokens with ETH. I'm following the sample at https://0x.org/docs/guides/swap-tokens-with-0x-api#swap-eth-for-1-dai. I got the token address, and the decimals. let's say ...