Linked Questions

5
votes
1answer
5k views

How to store a float or decimal in a contract? [duplicate]

I want to store the purchase price of a digital asset within the contract and then allow a user to purchase it. I have the following struct with some demo hard coded values but using a uint for the ...
3
votes
1answer
1k views

How to divide 11 wei by 2? [duplicate]

Do you know what should be the result of dividing suppose: 11wei by 2(integer value) = ? Thank you.
1
vote
1answer
253 views

How to Handle Decimals and Percentages in Solidity [duplicate]

Decimals and Percentages in Solidity I'm making function about percentage function setAddress(uint256 newValue) constant returns(uint256){ // tokenAddress = newAddress; // de a = 0.5; // ...
0
votes
1answer
169 views

ERC20 workaround for floats [duplicate]

I am reading about ethereum (from technology stand point). I want to create an ICO smart contract (a typical ERC20 test token) where say if someone sends 0.1 ether to the contract address then they ...
1
vote
0answers
133 views

which data type is use for decimal/float values [duplicate]

I am writing a contract in solidity which accept a float/decimal value. Perform some division operation and the function should return decimal value. Can anyone suggest which data type is use for ...
-1
votes
1answer
28 views

operation between uint256 and 1/100 [duplicate]

contrast take{ if ((address(this).balance)/100>=1/100){ } } The code above throws type error: incompatible type between uint256 and rational_const 1/100.does anyone know how to solve that?...
0
votes
0answers
20 views

How to handle floating point number in Solidity? [duplicate]

I read that there is no support for floating point number in solidity, So how we can handle it. If I want to store 12.23 or something like that.
19
votes
4answers
15k views

How can I perform float type division in solidity?

How can I achieve proper division of two integers in solidity? Suppose I perform : 3/2 the solution provided is 1 and not 1.5 please help.
12
votes
3answers
4k views

How does Ethereum cope with division of prime numbers?

I have seen this question here about representing decimals in solidity, and although of course the answer is that 'msg.value' is always in Wei, this got me thinking about how Ethereum handles division ...
5
votes
1answer
4k views

Max/min values of standard data types

Where can I find the maximum and minimum values that various types can store? And an epsilon value for floats? I'm looking for something like C's limits.h, but for Solidity / EVM.
5
votes
1answer
3k views

Is there a good way to calculate a ratio in Solidity (since there is no float/double)? [duplicate]

I've looked into the following answers, but have not found what I am looking for. How can I perform float type division in solidity? How can I represent decimal values in Solidity? How does ...