| 1216 | } |
| 1217 | |
| 1218 | IntegerType const* RationalNumberType::integerType() const |
| 1219 | { |
| 1220 | solAssert(!isFractional(), "integerType() called for fractional number."); |
| 1221 | bigint value = m_value.numerator(); |
| 1222 | bool negative = (value < 0); |
| 1223 | if (negative) // convert to positive number of same bit requirements |
| 1224 | value = ((0 - value) - 1) << 1; |
| 1225 | if (value > u256(-1)) |
| 1226 | return nullptr; |
| 1227 | else |
| 1228 | return TypeProvider::integer( |
| 1229 | std::max(numberEncodingSize(value), 1u) * 8, |
| 1230 | negative ? IntegerType::Modifier::Signed : IntegerType::Modifier::Unsigned |
| 1231 | ); |
| 1232 | } |
| 1233 | |
| 1234 | FixedPointType const* RationalNumberType::fixedPointType() const |
| 1235 | { |
no test coverage detected