mojira.dev
MC-279197

Some commands have inconsistent results for rounding negative numbers

The bug

Some commands, such as /data get, will round decimals down as their result. Other commands, such as /attribute ... get, will truncate decimals to a whole number, resulting in an inconsistency for handling negative numbers.

Affected commands

Commands that truncate decimals:

  • /attribute ... get ...

  • /execute store ... (byte|short|int|long) <decimal_scale>

  • /worldborder add <distance>

Commands that round decimals down:

  • /data get ...

The results for inserting decimals into integer arrays are also inconsistent, which has been reported in MC-276879, so I will skip them.

Ways to reproduce

To reproduce, you can either:

  • Install the attached data pack, and run /function mc-279197:test to see whether -7.3 is rounded to -7 or -8

  • Follow the steps below to test the specific cases between /data and /attribute

Steps to reproduce

  1. Summon a cow with a maximum health of 7.3

    /summon cow ~ ~ ~ {attributes: [{id: "minecraft:max_health", base: 7.3d}]}
  2. Create a scoreboard

    /scoreboard objectives add MC-279197 dummy
    /scoreboard objectives setdisplay sidebar MC-279197
  3. Attempt to store the maximum health via /data and /attribute

    /execute store result score data_get MC-279197 run data get entity @n[type=cow] attributes[{id: "minecraft:max_health"}].base -1
    /execute store result score attribute_get MC-279197 run attribute @n[type=cow] minecraft:max_health get -1
  4. Take note as to whether these two commands have consistent behavior for rounding negative numbers.

Observed results

/data rounds the result down to -8, while /attribute truncates the result to -7.

Expected results

The results of /data and /attribute should be the same, both being -7 or -8.

Linked issues

Attachments

Comments 2

Can confirm.

[media]

Thank you for your report!
After consideration, the issue is being closed as Won't Fix.

Please note that this is not the same as Working as Intended, as this bug report correctly describes behavior in the game that might not be the intended or desirable behavior, but it will not be fixed right now. Sometimes, this is because the issue reported is minor and/or impossible to change without large architectural changes to the code base.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

cxc81

(Unassigned)

Community Consensus

Commands

command

1.21.4, 25w02a, 25w03a, 25w04a, 25w05a

Retrieved