Questions tagged [decimals]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
433 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 ...
0
votes
2answers
61 views

Decimal in Solidity [duplicate]

I'm new to solidity but I program in other languages, solidity looks a bit like javascript but recently I noticed a problem with solidity. it doesn't accept decimals and float numbers, like "0....
0
votes
0answers
16 views

How to choose number of decimal places for token

What should I consider when choosing the number of decimal places for an ERC20 token/stablecoin? My first thought was to just use 18 which seems to be the standard because Ether uses 18. However ...
1
vote
1answer
17 views

ERC-20 interface decimal issue

i have created erc20 token with 100000 supply and decimal with 0. i wonder that if i ask an exchange to list my token. Are these decimal is problem? regards
0
votes
0answers
17 views

Vyper uint256 division with decimal precision

I am aware of this question here and the answer is correct however I am struggling to understand how to actually divide uint256 values with an arbitrary decimal precision Here is the function I am ...
0
votes
1answer
89 views

I'm confused about decimals and total Supply with my erc20 token

I created erc20 token. I want total supply of 50,00,000. And I want to give 7% tax on every transaction. So if anyone sends single coin then, how can I get 7% and transfer remaining to receiver? For ...
3
votes
2answers
260 views

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 ...
0
votes
0answers
199 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 ...
0
votes
1answer
36 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 ...
1
vote
1answer
123 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 ...
1
vote
1answer
786 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 ...
1
vote
1answer
85 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 ...
1
vote
1answer
102 views

Why don't decimals work in solidity?

I've read this question and answer thread about representing decimal values in solidity, and I understand that math is entirely done using fixed-point. However, I'm curious as to why this is the case. ...
0
votes
1answer
125 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 ...