Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Scratch sometimes doesn't follow my code. You should make it always follow code.
- 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:
Text that is rep'd by ‘…’: var ‘e’
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.
This should be in the help with Scripts. 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’
- 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.
What? @cheatcodeman , you are not supposed to be here.
hi, i'm on the forums and i create cool tech things, see below! oh and you should totally follow me, click here!
want a free game console? click here!
want a free phone? click here!
want a free computer? click here!
wanna listen to music? click here!
want to see a variety of cool tech things? click here!
- cheatcodeman
- Scratcher
1000+ posts
Scratch sometimes doesn't follow my code. You should make it always follow code.
Why not? @cheatcodeman , you are not supposed to be here.
- 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.
@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.
@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.'?
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.
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.
- Discussion Forums
- » Help with Scripts
- » Scratch sometimes doesn't follow my code. You should make it always follow code.