8k 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 ...
• 443
2k 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.
3k 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....
• 101
1 vote
2k views

How to set rate in decimals in solidity? [duplicate]

I want to set my price of token sale in ICO as 1 ether=0.0111111111. Since, solidity doesn't support decimals, what is suggested way to do that?
1 vote
730 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; // ...
• 133
416 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?...
366 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
146 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 ...
45 views

How to store values ​with decimal places? [duplicate]

I need to calculate values ​​for percentage and I need them to have two decimal places and the minimum value is 0.00 and the maximum value is 100.00. When I use some decimal place, for example: 80.01 ...
37 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.
20 views

how to store and use a fractionnal number for arithmetic operations in solidity? [duplicate]

I am trying to write a presale contract as an exercise that would allow the deployer to collect ether from buyers, then redistribute the amount of tokens proportionately to the amount spent by the ...
40k 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.
5k 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 ...
• 1,185
17k 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.
• 3,107