Discuss Scratch

littleDrongo
Scratcher
4 posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

I put some code to one of my 230 projects. I test-ran it and it didn't do an important piece of code. It was:
if <[ floor] = [1.79e308]> then
set [ floor] to [0]
change [ e] by (1.79)
set [ ef] to (join (join [...] [+]) (e308))

end

Text that is rep'd by ‘…’: var ‘e’

Last edited by littleDrongo (Dec. 9, 2021 22:09:28)

cheatcodeman
Scratcher
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

littleDrongo wrote:

I put some code to one of my 230 projects. I test-ran it and it didn't do an important piece of code. It was:
if <[ floor] = [1.79e308]> then
set [ floor] to [0]
change [ e] by (1.79)
set [ ef] to (join (join [...] [+]) (e308))

end

Text that is rep'd by ‘…’: var ‘e’
This should be in the help with Scripts.


littleDrongo
Scratcher
4 posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

@cheatcodeman , you are not supposed to be here.
9cjames1
Scratcher
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

cheatcodeman
Scratcher
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

littleDrongo wrote:

@cheatcodeman , you are not supposed to be here.
Why not?


RL1123
Scratcher
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

Scratch always follows code. In fact, it'll follow exactly what you tell it to do so there's probably a bug in your code.



through tough thorough thought, though














Signature #11
Paddle2See
Scratch Team
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

Looking for an exact match on something other than an integer number often leads to problems because what is shown by the computer does not align exactly with how it is stored and compared. I suggest that you change the comparison operator to greater than or less than (depending on which one makes sense in your application).

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
FatOldHen_ZTC
Scratcher
25 posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

littleDrongo wrote:

@cheatcodeman , you are not supposed to be here.

Why?


Scratcher for 3 years + age of this account

Also I'm a fat old hen who programs slot machines like this one.

Also also happy new year : P
littleDrongo
Scratcher
4 posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

In reply of @FatOldHen_ZTC
@cheatcodeman may be wrong.
littleDrongo
Scratcher
4 posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

In reply of @rayli1123
Well… there isn't a single bug in there. Then how could you say ‘so there’s probably a bug in your code.'?
deck26
Scratcher
1000+ posts

Scratch sometimes doesn't follow my code. You should make it always follow code.

Did you read @Paddle2See's explanation.

Imagine the value was 1/3 and Scratch displays it as 0.33 (keeping it simple) you might find checking if it equals 0.33 returns false because the way Scratch stores the value internally and what it displays won't necessarily match. Computers can store whole numbers precisely within a specified range for that language or system but once you exceed the range you should not assume the precision is exact.

In your case there is a range of values which Scratch may display as 1.79e308 so it doesn't make sense to look for an exact match. Presumably what you actually want to pick up is the value of the variable going over a certain limit so you need to use the > inequality.

Powered by DjangoBB