Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Help with Number Abbreviations
- EV2048
-
33 posts
Help with Number Abbreviations
Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
- TheOpalofTopaz
-
100+ posts
Help with Number Abbreviations
Sadly, there is another forum like this I believe. I won't report it as an exception! Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
- souleymane2
-
100+ posts
Help with Number Abbreviations
Hey there,
If you want to work on number abbreviations we're going to use parsing.
Lets start by checking if the last letter is either k (thousand) m (million) or b (billion). We can do so by taking advantage of the length of string block:
If thats not the case then well make sure it is indeed a number. To do so, were going to square it. If it returns a 0 then we know its incorrect as no numbers squares return 0.
Ok perfect. Now lets get to work. If the value is k then we want to multiply it by 1000. If its m then we want to multiply it by 1000000. And finally if its b we multiply it by 1000000000
Hope this helps!
If you want to work on number abbreviations we're going to use parsing.
Lets start by checking if the last letter is either k (thousand) m (million) or b (billion). We can do so by taking advantage of the length of string block:
If thats not the case then well make sure it is indeed a number. To do so, were going to square it. If it returns a 0 then we know its incorrect as no numbers squares return 0.
Ok perfect. Now lets get to work. If the value is k then we want to multiply it by 1000. If its m then we want to multiply it by 1000000. And finally if its b we multiply it by 1000000000
Hope this helps!
- SpyCoderX
-
1000+ posts
Help with Number Abbreviations
That won’t work. Hey there,
If you want to work on number abbreviations we're going to use parsing.
Lets start by checking if the last letter is either k (thousand) m (million) or b (billion). We can do so by taking advantage of the length of string block:
If thats not the case then well make sure it is indeed a number. To do so, were going to square it. If it returns a 0 then we know its incorrect as no numbers squares return 0.
Ok perfect. Now lets get to work. If the value is k then we want to multiply it by 1000. If its m then we want to multiply it by 1000000. And finally if its b we multiply it by 1000000000
Hope this helps!
What you will actually want to do is make another variable as the output we can have the actual value stay the same.
So, to make the abbreviated number:
First, check how big the number is.
Example: >=1000 we use K as the abbreviation
Then, we divide the number by a power of 10 based on the previous check.
For >=1000 we use 1000
Now, we can round the number down to 2 digits after the decimal place (1.00)
Note: >= is the same as not(<)
Full code:
- warriorcatsfreakalt
-
1000+ posts
Help with Number Abbreviations
Duplicate topics don't really matter in the Help with Scripts section, I believe. They're only an issue in the Suggestions, I think.Sadly, there is another forum like this I believe. I won't report it as an exception! Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
- SpyCoderX
-
1000+ posts
Help with Number Abbreviations
There is one case where duplicates still exist in HWS. If the same user creates 2 topics for the same issue, those are duplicates.Duplicate topics don't really matter in the Help with Scripts section, I believe. They're only an issue in the Suggestions, I think.Sadly, there is another forum like this I believe. I won't report it as an exception! Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
- EV2048
-
33 posts
Help with Number Abbreviations
Before I even saw all these posts, I finally figured it out! But can you help me with going over the quadrillions?
Then it just goes to the exponents.
Last edited by EV2048 (Sept. 1, 2024 16:55:16)
- EpicGhoul993
-
1000+ posts
Help with Number Abbreviations
Loop-based solution, with negative number support.
Yeah, it feels like the entire topic forgot about loops or something.
Yeah, it feels like the entire topic forgot about loops or something.
- EV2048
-
33 posts
Help with Number Abbreviations
Loop-based solution, with negative number support.I'm trying to make a clicker game, not like an ask and answer thing.
Yeah, it feels like the entire topic forgot about loops or something.
- EV2048
-
33 posts
Help with Number Abbreviations
I think I solved the problem!
https://scratch.mit.edu/projects/1067849190
https://scratch.mit.edu/projects/1067849190
- codeywhizz
-
100+ posts
Help with Number Abbreviations
https://scratch.mit.edu/projects/1067575984/
This project by this insanely handsome, talented, and smart scratcher seems to sort ur problem, click space to run, and also consider dropping a follow if it helped
This project by this insanely handsome, talented, and smart scratcher seems to sort ur problem, click space to run, and also consider dropping a follow if it helped
- bsteichman
-
500+ posts
Help with Number Abbreviations
here is a one liner that does this made by yours truly
have a list with the abbreviations in order EX:k,m,b,t
or drag the code from my project into your backpack!
have a list with the abbreviations in order EX:k,m,b,t
or drag the code from my project into your backpack!
Last edited by bsteichman (Sept. 14, 2024 20:25:44)
- EpicGhoul993
-
1000+ posts
Help with Number Abbreviations
So, like, just replace the ask and answer with your game code?????? Do you expect me to make an entire clicker to go with it? I'm trying to make a clicker game, not like an ask and answer thing.
- codeywhizz
-
100+ posts
Help with Number Abbreviations
will this work for scientific form tho? log becomes slightly inaccurate when put to massive numbers in java and scratch, causing ur calculations to go off here is a one liner that does this made by yours truly
have a list with the abbreviations in order EX:k,m,b,t
or drag the code from my project into your backpack!
Last edited by codeywhizz (Sept. 15, 2024 09:40:39)
- bsteichman
-
500+ posts
Help with Number Abbreviations
accurate to the first few digits, which is usually all you need. i doubt anyone that wants a number shortener wants like 1.327474983749387decillion they prolly would want just like 1.328 decillion.will this work for scientific form tho? log becomes slightly inaccurate when put to massive numbers in java and scratch, causing ur calculations to go off here is a one liner that does this made by yours truly
have a list with the abbreviations in order EX:k,m,b,t
or drag the code from my project into your backpack!
in my project, i have a way to round it to however many decimals as well.
- happywaffle0
-
100+ posts
Help with Number Abbreviations
Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
first, make a list on number abbreviations (dw I gotchu for some)
k, m, b, t, Qd, Qi, Sx ,Sp, Oc, No, D, UnD, DuD, TrD, QdD, QiD SxD SpD OcD NovD v… then so on
at the same time you could make the number abbrivation word thing full
then make a script (simplest form) like this
it appears the block is tooooooo long. use shift+arrow to view entire thing.
Last edited by happywaffle0 (Sept. 17, 2024 00:41:09)
- EV2048
-
33 posts
Help with Number Abbreviations
Or use quote to view the entire thing in text.Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
first, make a list on number abbreviations (dw I gotchu for some)
k, m, b, t, Qd, Qi, Sx ,Sp, Oc, No, D, UnD, DuD, TrD, QdD, QiD SxD SpD OcD NovD v… then so on
at the same time you could make the number abbrivation word thing full
then make a script (simplest form) like this
it appears the block is tooooooo long. use shift+arrow to view entire thing.
- EV2048
-
33 posts
Help with Number Abbreviations
Which one is it?Sadly, there is another forum like this I believe. I won't report it as an exception! Can anyone help me with number abbreviations? Like 1000=1k, 1000000=1m, etc.
- EV2048
-
33 posts
Help with Number Abbreviations
Just so you don't get confused, I want to find a list-free alternative. Not anything with
- happywaffle0
-
100+ posts
Help with Number Abbreviations
Just so you don't get confused, I want to find a list-free alternative. Not anything with
a list free alternative?
idk but this is the best one
Last edited by happywaffle0 (Sept. 25, 2024 12:14:00)
- Discussion Forums
- » Help with Scripts
-
» Help with Number Abbreviations