Small Basic includes Exponential Notation!!!

Here's a little-known factoid. This is great for those of you who are power users for Small Basic and using some "big math" in your programs!


You can find the latest version of this article on TechNet Wiki:

Small Basic: Scientific Notation


Let's get started!


Scientific notation is a way to write numbers that are too large or too small. For example, a microbiologist might need to measure cell growth up to 0.000000005 of a micron.

Use scientific notation to write the number 56,372.85 as 5.637285´104 (where 104 is 10000; the decimal goes to the right four spots). In most programming languages, you can use E-notation to represent decimal numbers.

In E-notation, the number 56,372.85 is written as 5.637285E4. The part of the number after the E is the power of 10. The E4 in this example means “times ten to the fourth power.” The Table shows you the E representation of some numbers.


Table: Examples of E-notation








5.6 E+07


Small Basic doesn’t treat E-notations like other numbers; you can’t assign an E-notation to a variable. For example, this statement gives you a syntax error:

x = 1.2E+02 ' This gives you a syntax error. You're welcome.

But if you put the E-notation in double quotes, then Small Basic recognizes it as a number! This is a parser feature to make it clear (to you and to Small Basic) that you meant it to be an E-notation. Try out this code snippet to get a hang of it:

x = "1.2E+02"   '= 120

y = "5.0E-02"   '= 0.05

z = "1.0E+03"   '= 1000

TextWindow.WriteLine(x + x)   'Answer = 240

TextWindow.WriteLine(x * y)   'Answer = 6.000

TextWindow.WriteLine(x / y)   'Answer = 2400 

TextWindow.WriteLine(z - x)   'Answer = 880

Now you can use E-notation when you need to!


Find the latest version of this article on TechNet Wiki:

 Small Basic: Scientific Notation


Small and Basically yours,

   - Ninja Ed & Majed Marji