Questions tagged [integers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
25 views

Synthetic uint512 out of 2 uint256

If I were trying to make a synthetic unsigned integer_512, but the largest supported integer in Ethereum is u256, how would I combine 2 u256 to make a single u512 in solidity? If I were also looking ...
-1
votes
1answer
46 views

what is the different between this two? [closed]

today I have two type One is like this pragma solidity ^0.5.0; contract Test{ function TestVar() view public returns(uint8){ uint8 a; for(uint8 b=0;b<20; b++){ a=b; } ...
0
votes
1answer
54 views

Why doesn't Solidity throw an error for overflows? [duplicate]

It seems like there are going to be a lot of people that forget to check for integer overflows in Solidity. I am wondering if there is a reason why Solidity doesn't throw errors for integer overflows ...
0
votes
1answer
202 views

Increment a uint variable results in unexpected value

I have the function resolveProject() in my contract, which iterates over a list of Task, let's say 2, both with status 3. function resolveProject() { // ... uint closedTask; uint ...
0
votes
2answers
75 views

Solidity: uint parameter not being set properly

Testing my contract locally with truffle. I have a function with the signature: function purchase(address buyer, address seller, bytes16 bookId, uint tokens) public onlyOwner returns(bool success) ...
1
vote
1answer
204 views

Truffle test: inputting an uint256 outputs a different result

To simplify my question, let's say I have a Test.sol with a function that simply output the input: function testFunc(uint256 value) public pure returns (uint256) { return value; } Now I want to ...
0
votes
2answers
616 views

How to store a Big Number?

I need to determine an expiry date for a contract a for this I use the foloowing code as the constructor of the contract : constructor(address _recipient, uint256 duration) public ...
1
vote
1answer
627 views

negative numbers passed to view functions are treated differently to negative numbers passed to transaction functions

Using solidity 0.4.18 I have the following contract: contract MyContact { mapping(address => uint) private balances; modifier positiveNumber(uint number) { require(number > 0);...
4
votes
2answers
17k views

What is uint256?

With regard to Solidity, What is UINT256? From the token example at https://ethereum.org/token : /* This creates an array with all balances */ mapping (address => uint256) public balanceOf; ...
0
votes
0answers
241 views

Invalid opcode during division

I have seen many posts around the division operation in Solidity e.g. Cant' do any integer division. Firstly, the error I am facing is different. Secondly, I am ensuring that, all numbers in division ...
1
vote
2answers
111 views

Can it be shown that `num > 0 && num < denom` is always the same as 0% < num / denom < 100%?

In Solidity, I want to check that the numerator and denominator passed to my function evaluate to 0% < num / denom < 100%. I tried the most direct approach: num / denom > 0 && num / ...
10
votes
4answers
5k 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 haven't been implemented yet but damn it should be possible to perform 100/3 = 33 ...
3
votes
1answer
477 views

How to store negative values inside {8||16||32} bits in populus?

I want to store -1 in smallest memory such as in {8||16||32} bits instead of 256 bits. int i = -1; When I return var, it returns -1L instead of -1. I have assigned -1 into a int8 variable. As I ...
7
votes
3answers
3k views

Type casting msg.value to uint248

I am new to solidity programming and sorry if my question is very basic. I am wondering if we can cast msg.value to uint248 Example below ; uint value; value = (uint248) (msg.value);
1
vote
2answers
156 views

Not able to read data from smart contracts

I am doing PoC on Ethereum using Azure Ethereum network and Web3. I was working from last 1 month and I have created one smart contract for student management and that was working like fab. But for ...
2
votes
0answers
95 views

VM jump when accessing statically set variables

Hey it seems I get a jump error when I try to access any variable not set through a parameter in the constructor. amountRaised is throwing a jump error below as I try to statically set the value. ...
7
votes
1answer
489 views

Difference between the assembly code generated for uint and uint32?

I wrote a simple contract with a single state variable with type uint and the generated assembly code is quite straight forward. But when I changed the type to uint32 the generated assembly becomes ...
4
votes
1answer
123 views

int256 range on geth command line

When I do the following on the geth command line: 20000000000000000000-19999999999999999989 it returns 0 I'm guessing this is because of a 64 bit limit on ints. Is there a way to get it to return ...
2
votes
3answers
507 views

Get order of magnitude of an integer in solidity

What is a way of getting the order of magnitude of an integer (or float) in a solidity contract? e.g. such that MyContract.getOrderMag(2564) returns 3 MyContract.getOrderMag(987) returns 2 ...