MCPcopy Create free account
hub / github.com/argotorg/solidity / fitsIntegerType

Function fitsIntegerType

libsolidity/ast/Types.cpp:73–82  ·  view source on GitHub ↗

Checks whether _value fits into IntegerType _type.

Source from the content-addressed store, hash-verified

71
72/// Checks whether _value fits into IntegerType _type.
73BoolResult fitsIntegerType(bigint const& _value, IntegerType const& _type)
74{
75 if (_value < 0 && !_type.isSigned())
76 return BoolResult::err("Cannot implicitly convert signed literal to unsigned type.");
77
78 if (_type.minValue() > _value || _value > _type.maxValue())
79 return BoolResult::err("Literal is too large to fit in " + _type.toString(false) + ".");
80
81 return true;
82}
83
84/// Checks whether _value fits into _bits bits when having 1 bit as the sign bit
85/// if _signed is true.

Callers 2

fitsIntoBitsFunction · 0.85

Calls 4

isSignedMethod · 0.45
minValueMethod · 0.45
maxValueMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected