This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-11-22 08:39:54

IndianEducator
New Scratcher
Registered: 2010-11-11
Posts: 1

Bug: Parsing Problem: Space after the negative sign (-) makes number 0

Hi,

I declared a variable to which I wanted to assign a negative value. When I assigned the value as "- 0.5", the value was treated as 0. This is because of the space between the negative sign and 0.

Example:
[blocks]<set{ negativehalf }to(- 0.5 [/blocks]

In places where numbers are used directly this is not a problem since the editor doesn't allow the insertion of a space after the negative sign. For variables though, where there's no type checking, this turns out to be a problem.

The fix would be to loosen the constraints for parsing numbers.

regards,
Saurabh

Offline

 

#2 2010-11-22 19:30:10

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: Bug: Parsing Problem: Space after the negative sign (-) makes number 0

You're right, Scratch can't recognize spaces within numbers. This is because as soon as you add a space, Scratch thinks the variable is a string, and returns 0 in places where only numbers can be used.

For that reason, you'll have to use "-0.5" instead of "- 0.5". Sorry.


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

Board footer