in reply to Strange behaviour when printing certain numeric values
Then at runtime when perl has to try to figure out what to do at "$_ + 1", it probably does a bunch of logic to decide whether to do floating point addition or integer addition, and that function in the PR was previously returning True to indicate that lossless conversion from NV to IV *is* possible, and somehow it used the NV for the calculation but cached the IV back into the SV struct. Going forward, the SV appears to be both an NV and IV and so later addition uses integer math since it is faster. But, that wasn't true because the NV already lost the low 7 bits or so of the IV, so the IV is incorrect/not accurate and should not have been cached into the SV. After the patch, the lossless conversion function will return false, will not cache the IV, and should keep using NV math on each repeat operation.
It seems like maybe a better fix would be to tell the parser to record the integer value at parse time since it would fit, but I really don't know enough about the parser internals to make a recommendation like that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange behaviour when printing certain numeric values
by hv (Prior) on Jan 17, 2024 at 19:55 UTC | |
by syphilis (Archbishop) on Jan 18, 2024 at 02:54 UTC | |
|
Re^2: Strange behaviour when printing certain numeric values
by choroba (Cardinal) on Jan 17, 2024 at 19:11 UTC |