Issue
I'm trying to declare the value as a negative number, but I'm not quite sure how to do this.
pragma solidity ^0.8.4;
contract Contract {
int8 public a;
int8 public b;
int16 public difference = a - -b;
}
Solution
You can't give a negative number to uint
, instead you should use int.
What you are looking for:
contract Contract {
int8 public a = 3;
int8 public b = -3;
int16 public difference = a - -b;
//If it did not work, change above line to this:
//int16 public difference = a - b;
}
Answered By - Ahmad Gorji Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.