-
Bug
-
Resolution: Unresolved
-
None
-
1.21.1, 24w38a
-
Confirmed
-
Commands
-
Low
-
Platform
Using `data modify storage ...`, you can cast a float or double to a byte, int, or long by appending it to an array of the corresponding type. When doing this, all cases round down, except appending a float to a long array, which truncates the value instead.
How to reproduce:
- Run commands to create byte, int, and long arrays:
/data modify storage test byte set value [B;] /data modify storage test int set value [I;] /data modify storage test long set value [L;]
- Append a float and a double to each array. Make sure the number is negative and not an integer, so that truncating behaves differently than rounding down.
/data modify storage test byte append value -1.5f /data modify storage test byte append value -1.5d /data modify storage test int append value -1.5f /data modify storage test int append value -1.5d /data modify storage test long append value -1.5f /data modify storage test long append value -1.5d
- Get the values of the arrays:
/data get storage test
- You can see that both the byte and int arrays are [-2, -2], while the long array is [-1, -2], meaning that the float got truncated instead of rounded down when cast to a long.
I would expect that all cases would be consistent, rather than having one combination that behaves differently than all of the others.