Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point numbers that end in .0 cannot be added to blocks #157

Open
mybearworld opened this issue Sep 1, 2024 · 1 comment · May be fixed by #214
Open

Floating point numbers that end in .0 cannot be added to blocks #157

mybearworld opened this issue Sep 1, 2024 · 1 comment · May be fixed by #214

Comments

@mybearworld
Copy link

Expected Behavior

It should be possible to create a pick random (1.0) to (10) block. (This makes the block output a floating point number instead of an integer.)

Screenshot from regular Scratch
pick random 1.0 to 10 block with 3.4339879999682923 as its output

Actual Behavior

Whenever you enter 1. or 1.0 into a block, it autocorrects to "1".

Steps to Reproduce

  • Drag out any block that takes in a number.
  • Try to enter "1.0".

Operating System and Browser

Windows 11 on MS Edge 128

@GrahamSH-LLK
Copy link

GrahamSH-LLK commented Sep 4, 2024

This is caused by the original scratch-blocks and modern Blockly implementations for decimals being very different- scratch-blocks has a custom rolled(?) regex implementation that simply checks for periods in the string. Blockly has a more robust approach that ends up stripping that "unneeded" decimal that VM relies on for the random behavior. I believe it happens here

Edit: this behavior was briefly fixed in #54 but was reverted

@gonfunko gonfunko linked a pull request Oct 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants