Add `get_half` and `put_half` on `StreamPeer`
This pull request implements get_half and put_half, closes https://github.com/godotengine/godot-proposals/discussions/5983
The code is using Math::half_to_float and Math::make_half_float.
Using them results - as expected - in lose of precision.
This is an example script that uses them:
var peer := StreamPeerBuffer.new()
var input_value := 15.1234
var expected_value := 15.1171875
prints(peer.get_size() == 0)
peer.put_half(input_value)
prints(peer.get_size() == 2)
peer.seek(0)
prints(peer.get_half() == expected_value)
The output should be:
true
true
true
I don't know.
If the changes in this PR are still wanted, I can try to rebase with the latest changes on master after https://github.com/godotengine/godot/pull/95784 got merged (in order to be able to add tests for this two new methods)
BTW, the rebase will require that I create a new PR with this changes. @theraot if you agree with that I'll add you as a Co-Author of that PR because most of the code will be yours.
@pafuent you can go ahead.
- Superseded by https://github.com/godotengine/godot/pull/97716. Thanks for the contribution nonetheless!