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

#1 2009-05-04 05:30:36

p120ph37
Scratcher
Registered: 2009-05-04
Posts: 1

Obscure float/string casting bug.

Code:

<when green flag clicked>
<delete ( all ) of { q } >
<add ( 0.0005 / 5000 ) to { q }>
<think ( [item ( 1 ) of { q }] * 1 )>
<end script>

Notice that the division and insert into a list variable (with the implicit cast to a string type that this entails) produces a value in scientific-notation within the list.

The forced cast back to a numeric value via the multiplication operator fails to properly parse the scientific notation and results in only the mantissa being evaluated without the exponent.

This could be remedied either by avoiding the use of scientific notation when inserting into list variables as seems already to be the case with non-list variables, or by enhancing the number-parser to correctly interpret scientific notation.

-Aaron

Offline

 

#2 2009-05-12 18:33:16

imacat
Scratcher
Registered: 2008-05-30
Posts: 100+

Re: Obscure float/string casting bug.

uhhh.... i'll try it out on scratch and see what you're talking about.


"if you say something is stupid, that means you are. Unless it's on AFV."
-imacat   btw, this is NOT a link to a website otherwise inaccessible. ;-)

Offline

 

#3 2009-05-12 18:36:36

imacat
Scratcher
Registered: 2008-05-30
Posts: 100+

Re: Obscure float/string casting bug.

i don't get it.


"if you say something is stupid, that means you are. Unless it's on AFV."
-imacat   btw, this is NOT a link to a website otherwise inaccessible. ;-)

Offline

 

#4 2009-05-13 13:20:04

Mitch101
Scratcher
Registered: 2009-01-19
Posts: 15

Re: Obscure float/string casting bug.

lol someone gets A's in english, but it makes sense and yes that is a glich

Offline

 

#5 2009-05-13 18:43:55

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Obscure float/string casting bug.

This problem is on the bug list.  Thanks for bringing it up!


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#6 2009-05-13 22:50:46

GoogleplexPlus
Scratcher
Registered: 2009-04-16
Posts: 1000+

Re: Obscure float/string casting bug.

What he means is, the system was confused by exponents.

Offline

 

#7 2009-05-13 22:52:10

ScratchX
Scratcher
Registered: 2009-05-05
Posts: 1000+

Re: Obscure float/string casting bug.

oh it is a glitch i tested it out


Happy New Year!
http://i45.tinypic.com/1nyasi.pnghttp://i50.tinypic.com/219pez8.pnghttp://i49.tinypic.com/e5s4zr.pnghttp://i48.tinypic.com/23l18hf.jpghttp://i49.tinypic.com/66zymu.png

Offline

 

#8 2009-05-18 17:40:13

scratchisthebest
Scratcher
Registered: 2009-02-08
Posts: 500+

Re: Obscure float/string casting bug.

If you need help, here are some terms:
1. Mantissa: The whole number part of a decimal.
2. Exponent: The fractional portion.
3. String: A "string" of characters (hence the name)
4. Scientific notation: A number that includes the letter E. (e.x. 1.0E6 = 1,000,000)
EDIT: I learned the first 2 in a C/C++ book written for people double my age! 3 from a Java book, and 4 I figured out.

Last edited by scratchisthebest (2009-05-18 17:41:41)


bye 1.4, we all loved you. but we all outgrew the site. 2.0 is a welcome change.
http://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.pnghttp://scratch.mit.edu/img/Pico3-med.png

Offline

 

Board footer