Discuss Scratch
- Discussion Forums
- » Suggestions
- » Decimals!
- scmb1
-
Scratcher
100+ posts
Decimals!
I was just making a little e calculator and remembered a problem I sometimes have with numbers in Scratch– they tend to round off at a few decimal places. This works just fine most of the time, but for some projects it can be useful to show more (like e and pi generators for instance.) For a while I was making a bunch of projects that required more decimal places and I used something I liked to call the “join trick” (http://scratch.mit.edu/forums/viewtopic.php?id=30650). Putting an expression inside of a join block caused the number not to be rounded quite so much. This still works, but not many Scratchers know about it. Would it be useful to have a more obvious way to do this? Maybe a special block or setting that lets numbers have more decimal places?
Here's that e project, with and without the join trick: http://alpha.scratch.mit.edu/projects/10003629/?mode=player
Here's that e project, with and without the join trick: http://alpha.scratch.mit.edu/projects/10003629/?mode=player
- johnm
-
Scratcher
100+ posts
Decimals!
One way to handle this would be to have a menu option on variable monitors to control how many digits to show after the decimal point. I'll add this to the feature “wish list”.
The “join” trick is clever. It works by forcing the to be represented as a string with many digits of precision. Then the variable monitor sees it as a string, not a number, and doesn't do any rounding.
Thanks for the suggestion!
– John
The “join” trick is clever. It works by forcing the to be represented as a string with many digits of precision. Then the variable monitor sees it as a string, not a number, and doesn't do any rounding.
Thanks for the suggestion!
– John
Last edited by johnm (Sept. 11, 2012 18:50:14)
- scmb1
-
Scratcher
100+ posts
Decimals!
johnm
One way to handle this would be to have a menu option on variable monitors to control how many digits to show after the decimal point. I'll add this to the feature “wish list”.
The “join” trick is clever. It works by forcing the to be represented as a string with many digits of precision. Then the variable monitor sees it as a string, not a number, and doesn't do any rounding.
Thanks for the suggestion!
– John
That sounds like a great solution to me.
- TW301
-
Scratcher
10 posts
Decimals!
Im trying to make a game which will determine the attributes of a character (strength & skill) and i am not sure on how to round the overall score down to one significant figure (no decimal place). It would be a great help if someone has been in this position before and would be able to help solve this problem. It is currently very annoying and it is for a project i am currently working on which needs to be completed ASAP, so if someone could get back to me as quick as possible that would be amazing!
Many thanks
-TW301
Many thanks
-TW301
- mathfreak231
-
Scratcher
1000+ posts
Decimals!
Im trying to make a game which will determine the attributes of a character (strength & skill) and i am not sure on how to round the overall score down to one significant figure (no decimal place). It would be a great help if someone has been in this position before and would be able to help solve this problem. It is currently very annoying and it is for a project i am currently working on which needs to be completed ASAP, so if someone could get back to me as quick as possible that would be amazing!
Many thanks
-TW301
([floor v] of (score))Also please be careful when bringing up a two-year-old topic.
- TW301
-
Scratcher
10 posts
Decimals!
How do I incorporate this code into
It just keeps coming up as infinity…..
Its starting to get very irritating, as I have tried many different ways of changing the code.
-TW301
set [ strength] to [ ((12 sided dice) / (4 sided dice))]
It just keeps coming up as infinity…..
Its starting to get very irritating, as I have tried many different ways of changing the code.
-TW301
- Blaze349
-
Scratcher
1000+ posts
Decimals!
How do I incorporate this code intoset [ strength] to [ ((12 sided dice) / (4 sided dice))]
It just keeps coming up as infinity…..
Its starting to get very irritating, as I have tried many different ways of changing the code.
-TW301
Im trying to make a game which will determine the attributes of a character (strength & skill) and i am not sure on how to round the overall score down to one significant figure (no decimal place). It would be a great help if someone has been in this position before and would be able to help solve this problem. It is currently very annoying and it is for a project i am currently working on which needs to be completed ASAP, so if someone could get back to me as quick as possible that would be amazing!
Many thanks
-TW301([floor v] of (score))Also please be careful when bringing up a two-year-old topic.
- Harakou
-
Scratcher
1000+ posts
Decimals!
Unless your problem is very closely related, please make a new topic to ask for help instead of bumping up an old one. (Preferably in “Help with Scripts”)
- Discussion Forums
- » Suggestions
-
» Decimals!




