Numeric Infinity (1/0) turns into "0" when saving to sb2 format
See original GitHub issueExpected Behavior
In scratch 2: You should be able to save the value (1/0) (constructed using the () / ()
operator block). The value is listed as Infinity
in the list or variable.
Actual Behavior
In scratch 2: You cannot save the value (1/0) (constructed using the () / ()
operator block). The value is listed as Infinity
, then is turned into 0
in the sb2 creation.
Steps to Reproduce
- Either:
a. Create a variable.
b. Give the variable the value (1/0) (using the
() / ()
operator block) using theset () to ()
block. - Or:
a. Create a list.
b. Add the value (1/0) (using the
() / ()
operator block) to the list using theadd () to ()
block. - Notice that the number shows up as
Infinity
in the visual representation of the list or variable. - Save the project and download the program.
- Exit the window.
- Notice:
a. The value has turned to
0
b. If you inspect the project.json, the value there is0
as well
See this project for an example: https://scratch.mit.edu/projects/260496681/#editor
This may or may not be a compatibility issue with scratch 3.
Operating System and Browser
Debian 10 and Firefox 62
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
CSV losing leading zeros and number changing - YouTube
00:00 Losing leading zeros and big numbers from CSV's00:20 Convert CSV to columns00:35 Example of lost zeros and numbers changed at end01:13 ...
Read more >tLx - River Thames Conditions - Environment Agency - GOV.UK
Locating non negative rational numbers, Best netbook distro 2014, Streaming tv online reviews, Signpost maths 10 enhanced, Arkema clear lake expansion.
Read more >NS-Series Programmable Terminals PROGRAMMING MANUAL
Provides information on existing NS Series models (i.e., NS12, NS10, ... If the exponent is 11111111 and the mantissa is 0, the number...
Read more >User's Manual Code Version 6.2 - MCNP
number, with "0" indicating a void; and the third number (in this case) provides cell surface information. In this sample problem, ...
Read more >Cisco Unified Communications Manager Express System ...
<1-10> template tag> Router(config-voice-auto-register)#template 10 ... adaptor that turns traditional telephone devices into IP devices.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For some more context, this actually is a problem for saving scratch3 projects:
In Scratch3, the variable gets serialized using JSON.stringify, which does not work with values like
Infinity
orNaN
(see here for why), so they get serialized tonull
, which then makes the parser fail. that makes the project not loadable by file input, and cannot be saved on the server because validation fails (null is not a number or string).Found by @ericrosenbaum
But then Infinity and NaN get weird when stored… why not use a custom serializer or at least a third-party one that handles such values properly?