If you expect your smart contract to perform mathematical calculations, refrain from using arithmetic operators like plus(+), minus(-), multiply(*), divide(/), and modulus (%). Without proper checks, they have the potential to introduce underflow and overflow vulnerabilities.
Use Openzeppelin’s SafeMath library for unsigned integer operations.https://betterprogramming.pub/media/ac434b4d8b7dddfea73535fafd717396.
pragma solidity ^0.5.5;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract BasicSafeMath {
using SafeMath for uint;
function doSomeMath(uint _a, uint _b) public returns (uint) {
return _a.sub(_b);
}
}