| 341 | } |
| 342 | |
| 343 | Value castValue(Value value, const ValueType::Sign sign, nonneg int bit) |
| 344 | { |
| 345 | if (value.isFloatValue()) { |
| 346 | value.valueType = Value::ValueType::INT; |
| 347 | if (value.floatValue >= std::numeric_limits<int>::min() && value.floatValue <= std::numeric_limits<int>::max()) { |
| 348 | value.intvalue = static_cast<MathLib::bigint>(value.floatValue); |
| 349 | } else { // don't perform UB |
| 350 | value.intvalue = 0; |
| 351 | } |
| 352 | } |
| 353 | if (bit < MathLib::bigint_bits) { |
| 354 | constexpr MathLib::biguint one = 1; |
| 355 | value.intvalue &= (one << bit) - 1; |
| 356 | if (sign == ValueType::Sign::SIGNED && value.intvalue & (one << (bit - 1))) { |
| 357 | value.intvalue |= ~((one << bit) - 1ULL); |
| 358 | } |
| 359 | } |
| 360 | return value; |
| 361 | } |
| 362 | |
| 363 | std::string debugString(const Value& v) |
| 364 | { |
no outgoing calls
no test coverage detected