question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Numeric Infinity (1/0) turns into "0" when saving to sb2 format

See original GitHub issue

Expected 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

  1. Either: a. Create a variable. b. Give the variable the value (1/0) (using the () / () operator block) using the set () to () block.
  2. Or: a. Create a list. b. Add the value (1/0) (using the () / () operator block) to the list using the add () to () block.
  3. Notice that the number shows up as Infinity in the visual representation of the list or variable.
  4. Save the project and download the program.
  5. Exit the window.
  6. Notice: a. The value has turned to 0 b. If you inspect the project.json, the value there is 0 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:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
paulkaplancommented, Dec 3, 2018

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 or NaN (see here for why), so they get serialized to null, 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

0reactions
Kenny2githubcommented, Dec 4, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found