-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Closed
Description
// multiply last value by ten and add the new digit
auto temp = value * 10 + *curptr - '0';
// test for overflow
if (temp < value || temp > max)
{
// overflow
type = value_t::number_float;
}The temp < value above will not detect overflow for some values, as we're not just adding a small value, but also multiplying by 10, so this may overflow couple of times over and end-up satisfying temp >= value. As for temp > max - it looks to me that it will never happen unless the width of temp is greater than that of max
Try round-tripping 166020696663385964490
Reactions are currently unavailable