Linked Questions

6 votes
1 answer
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 ...
ORStudios's user avatar
  • 443
4 votes
1 answer
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.
alexey polusov's user avatar
0 votes
2 answers
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....
M4theuz's user avatar
  • 101
1 vote
3 answers
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?
Fariha Abbasi's user avatar
1 vote
1 answer
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; // ...
Hassan Abbas's user avatar
-1 votes
1 answer
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?...
user54746's user avatar
0 votes
1 answer
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 ...
kiranvaidya's user avatar
1 vote
0 answers
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 ...
jambu gunvant's user avatar
0 votes
2 answers
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 ...
THIAGO DE BONIS's user avatar
0 votes
0 answers
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.
Rishabh Singh's user avatar
0 votes
0 answers
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 ...
ian3111's user avatar
30 votes
5 answers
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.
Vaibhav Tiwari's user avatar
13 votes
3 answers
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 ...
T9b's user avatar
  • 1,185
14 votes
2 answers
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.
Tom Hale's user avatar
  • 3,107
16 votes
1 answer
7k views

What fixed or float point math libraries are available in Solidity?

Solidity doesn't have fixed-point, floating-point, or double types. What solutions are there to handle the cases where we really have to represent numbers as percentages or fractions?
Paul Razvan Berg's user avatar

15 30 50 per page