Negative numbers using scientific notation are treated as strings

1 sentence description of the problem: Negative numbers that use scientific notation (for example, -3.14e-7) are always treated as strings. This is particularly annoying since such numbers can be returned from math blocks.

Steps to reproduce the problem every time:

  1. Create a variable containing a negative number that is represented with scientific notation
  2. Attempt to do something that requires it to be a number. (For example, multiplying)

I expected this to happen: It to be treated as a number.

But instead this happened: It was treated as a string, even in addition blocks.

Screenshots/video: https://c.gethopscotch.com/p/12y4mjr3rn In this project it uses the concatenation ability of the + block instead of addition. With the new join block, is allowing concatenation with the addition block necessary in newer players?


Your username: Petrichor

Device type, iOS version: iPhone 8

Hopscotch version & player version: 3.63.0, 2.2.0

9 Likes

The join text operator has some very small problems compared to the addition math operator. I literally tried to change all of the + type of concatenation to join. I know I changed them all correctly, yet. Everything got bugged. When I went back to (+), it worked as expected.

2 Likes

It looks like the problem was with Hopscotch not recognising e^-7 as a number and treating it as a string – we have a fix for this. Thanks again for the report here too.

2 Likes

After the fix in 2.2.1, math operators should definitely convert to numbers at time of calculation where possible, including Add.

I think the support for strings has been for the case of new users entering strings into variables – the aim is to have the blocks still work as they might expect.

2 Likes

This should be fixed now in webplayer 2.2.1 (just released)

2 Likes

This topic was automatically closed after 11 days. New replies are no longer allowed.