Questions tagged [fixed-point]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
123 views

Converting Uniswap sqrtPriceX96 into wei

I'm trying to figure out how to convert a uniswap ratio into wei (and eventually ether). The uniswap docs commonly mention sqrtPriceX96: A Fixed point Q64.96 number representing the sqrt of the ratio ...
0
votes
1answer
29 views

How in Solidity can you get initial value from the sum of ratios to it?

In Solidity division of uint256 rounds down the value. Let's say I want to issue some token amount based on duration like this: uint256 MAX_TIME = 365 days; uint256 Duration1 = 223 days; uint256 ...
0
votes
0answers
59 views

DeclarationError: Identifier already declared even with inline function call

I got error in my smart contract, Pool.sol:10:1: DeclarationError: Identifier already declared. import './ERC20.sol'; ^------------------^ Token.sol:10:1: The previous declaration is here: contract ...
0
votes
1answer
36 views

Rounding fixed point integers

If I'm using fixed-point arithmetic to represent rates, for example, 2% in ray (27 decimal precision) would be 102000000000000000000000000000. If I had a rate like 101333333333333333333333333333 (1.33%...
0
votes
0answers
31 views

Can't store the value of a math operation. It's always 0

contract MyContract { uint public priceUSD = 1.70 * 10**8; // USD uint public priceEth; ......... function setPrice(uint newPriceUSD) external ownerOnly() returns(uint, uint) { uint ...
1
vote
1answer
104 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. ...
16
votes
4answers
11k views

Can't do any integer division

I'm building a new smart contract but really can't figure out how to perform integer division. I know that fixed point numbers haven't been implemented yet but it should be possible to perform 100/3 = ...