0

In my program, I have a large string of numbers that have been compiled together, and I'm switching it back and forth between different base values. But when I switch back to decimal, the computer directly switches to a number using exponential notation. The program I'm using is Scratch, but as long as any algorithms that are given are readable, I should be able to translate.

Essentially, I just need a way to go from like 1.0e13 to 10000000000000. Any ideas?

Anm
  • 3,291
  • 2
  • 29
  • 40
Pramerios
  • 1
  • 2
  • 5
    The `e` here is not Eulers number - it's an *exponential* notation, but `1.0e13` means `1.0 * 10^13`, not `1.0 * e^13`. Using exponential notation for very large/small numbers is very common, and it's normally just presentation. To avoid it, usually there's a way to specify other presentations, either directly on output or (as Marii suggests) using a conversion to a string. –  Mar 13 '17 at 22:43
  • Sorry - not a conversion to a string, that looks like a conversion to a decimal number type, which will naturally have the same issues that we're used to with decimal numbers but not the extra ones that happen with binary. –  Mar 13 '17 at 22:51

2 Answers2

2

This script is the best I could muster:

convert (number) to standard decimal block

And a sample output:
sample output script
enter image description here

As well as a project containing the custom block for your convenience: https://scratch.mit.edu/projects/150067538/

Unfortunately, Scratch still rounds numbers, so your answers won't always be 100% exact, but at least they won't be in scientific (e) notation. If somebody else has an even better solution, I'd love to see it.

PullJosh
  • 735
  • 7
  • 21
  • The rounding error is common on most computer programs and how they represent the number in the CPU. There are only so many numbers you can represent with 32 or 64 bits. https://www.youtube.com/watch?v=PZRI1IfStY0 – Anm Jul 21 '17 at 16:29
0

Like PullJosh said, (Hey again PullJosh!) scratch rounds numbers off the Scientific Notation so it won't be exactly accurate but their is always a solution to a problem!



My theory is that you can put each digit of the scientific notation into a list. This will make the conversion much easier! I will not take a picture of my code but send you the link to it as the code is massive mostly because I added some code that will detect if your scientific notation is a number and it can convert numbers like 1.123e2.

https://scratch.mit.edu/projects/341550388/editor
You can use the code without credit,yay! Just put it in your backpack and you're good to go.

Edit: Also, if you need more help with Scratch and stuff, feel free to follow me @ endermite334 (you don't have to) and I will be happy to help you!

Mr PizzaGuy
  • 410
  • 6
  • 19