Numbers

Numbers in ToonTalk are not like numbers in other programs. Integers can be any size (that fits in memory). Creating a number with a million digits can take a minute or two but adding two of them takes just a second. All numbers are really fractions whose numerator and denominator can be any size. Integers are just numbers whose denominator happens to be one. Fractions can be displayed as decimal numbers, mixed numbers (an integer together with a fraction between 0 and 1), scientific notation, or improper fractions.

Adding numbers

The easiest thing to do with numbers is to add them. Dropping a number on another combines them by addition. Try adding a Googol (one followed by one hundred zeroes) to a one by picking up the Googol below and dropping it on the one. You might want to stretch the result to see it better.


{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "denominator": "1", "format": "improper_fraction", "infinite_stack": true }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 46, "frontside_top": 46, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 76, "frontside_height": 55, "frontside_left": 63, "frontside_top": 201 }, "version": 1 } } ] }, "view": { "background_color": "rgba(245, 240, 240, 0.941176)", "frontside_width": 0, "frontside_height": 0, "backside_width": 595, "backside_height": 381, "backside_left": 8, "backside_top": 185.1875, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 1200, "original_height": 475 }, "drag_x_offset": 303, "drag_y_offset": 268.8125, "backside": true }, "version": 1 }

Try adding another Googol to the sum.

Question: Could a computer hold a Googolplex (one followed by a Googol zeroes)? Hover the mouse over this for an answer.

Editing numbers

If you click on a number its backside will appear. On the backside you can edit the numerator or denominator. Click on the Googol and try changing the denominator to 2. Try changing the denominator to 3.

Displaying numbers

Suppose you want to see your number (1/6th of a Googol because you divided by 2 and then by 3) in different ways. On the backside of things in ToonTalk you'll see a > button. Click on your number's > button to see advanced options. Click on it again to hide these options.

You should see something like this:

This will be replaced by a work area containing 3 things: a number, a number, and the backside of a number. top level widget
{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "shared_widget_index": 0 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 339, "frontside_height": 55, "frontside_left": 69, "frontside_top": 207, "backside": false }, "version": 1 } }, { "widget": { "shared_widget_index": 0 }, "is_backside": true } ] }, "view": { "background_color": "rgb(245, 240, 240)", "backside_width": 1093, "backside_height": 420, "backside_left": 8, "backside_top": 184.1875, "advanced_settings_open": true, "backside": true, "drag_x_offset": 416, "drag_y_offset": 404.8125 }, "version": 1, "shared_widgets": [ { "semantic": { "type": "number", "operator": "+", "numerator": "5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "denominator": "3", "format": "improper_fraction", "infinite_stack": true }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 52, "frontside_top": 52, "backside_width": 550, "backside_height": 362, "backside_left": 522.65625, "backside_top": 21.65625, "advanced_settings_open": true, "backside_geometry": { "x_scale": 1, "y_scale": 1.8099999999999983, "original_width": 550, "original_height": 200 }, "saved_width": 444, "saved_height": 55, "backside": false }, "version": 1 } ] }

Try clicking on Mixed number.

Question: Do you understand the result? Hover the mouse over this for an answer.

Try clicking on Decimal.

Question: Do you understand this result? Hover the mouse over this for an answer.

Try clicking on Scientific notation.

Question: Do you understand this result? Hover the mouse over this for an answer.

Mulitplying numbers

The advanced options on the backside can change how numbers are combined from the default of addition to multiplication. Click on the 10,000,000,000 below (also known as ten billion or ten-plex), then on the > button, and then on ×. Drop the multiply by the ten-plex on the 1. Try it again.

Question: Do you understand the result? Hover the mouse over this for an answer.

Question: What do you get if you do the multiplication eight more times? Hover the mouse over this for an answer.

{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "10000000000", "denominator": "1", "format": "proper_fraction", "infinite_stack": true }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 46, "frontside_top": 46, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 56, "frontside_top": 167, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } } ] }, "view": { "background_color": "rgba(245, 240, 240, 0.941176)", "frontside_width": 0, "frontside_height": 0, "backside_width": 998, "backside_height": 294, "backside_left": 8, "backside_top": 185.1875, "backside_geometry": { "x_scale": 1, "y_scale": 1 }, "drag_x_offset": 702, "drag_y_offset": 174.8125, "backside": true }, "version": 1 }

Subtracting numbers

One way to subtract one from a Googol is to click on one of the ones, then on >, and then . Then drop the subtract one operator on the Googol.


{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "denominator": "1", "format": "proper_fraction" }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 54, "frontside_top": 201, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "proper_fraction" }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 51, "frontside_top": 17, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "proper_fraction" }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 54, "frontside_top": 107 }, "version": 1 } } ] }, "view": { "background_color": "rgba(245, 240, 240, 0.941176)", "frontside_width": 0, "frontside_height": 0, "backside_width": 998, "backside_height": 294, "backside_left": 8, "backside_top": 185.1875, "backside_geometry": { "x_scale": 1, "y_scale": 1 }, "drag_x_offset": 652, "drag_y_offset": 173.8125, "backside": true }, "version": 1 }

Another way to subtract is to add a negative number. Click on the remaining one and edit its numerator to be -1. Drop the add minus one operator on the other number.

Question: Do you see why both ways of subtracting do the same thing? Hover the mouse over this for an answer.

Dividing numbers

Click on the fifty-plex below, then >, then ÷. Drop it on the one. Click on the result (it can be called a fifty-minex). Change its format to Decimal Number. The result looks like zeroes forever. Try stretching it wider until you see the final one.

{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "100000000000000000000000000000000000000000000000000", "denominator": "1", "format": "proper_fraction", "infinite_stack": true }, "view": { "frontside_width": 444, "frontside_height": 55, "frontside_left": 57, "frontside_top": 30, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } }, { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 449, "frontside_height": 55, "frontside_left": 62, "frontside_top": 179, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 } }, "version": 1 } } ] }, "view": { "background_color": "rgba(245, 240, 240, 0.941176)", "frontside_width": 0, "frontside_height": 0, "backside_width": 1046, "backside_height": 277, "backside_left": 8, "backside_top": 185.1875, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 1200, "original_height": 475 }, "drag_x_offset": 614, "drag_y_offset": 185.8125, "backside": true }, "version": 1 }

Setting a number to the value of another

You can use the = operator so that that number when dropped on another number turns that number into the new value. This is simpler and faster than the alternative of converting a number into another by multiplying it by zero and then adding the value desired.

Try dropping the "=2" on the "1".

This will be replaced by a work area containing 3 things: a number, a number, and the backside of a number. top level widget
{ "semantic": { "type": "top_level", "backside_widgets": [ { "widget": { "semantic": { "type": "number", "operator": "+", "numerator": "1", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 76, "frontside_height": 55, "frontside_left": 82, "frontside_top": 52, "saved_width": 76, "saved_height": 55, "backside": false }, "version": 1 } }, { "widget": { "shared_widget_index": 0 } }, { "widget": { "shared_widget_index": 0 }, "is_backside": true } ] }, "view": { "background_color": "rgba(245, 240, 240, 0.941176)", "backside_width": 880, "backside_height": 487, "backside_left": 8, "backside_top": 184.1875, "advanced_settings_open": true, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 1136, "original_height": 467 }, "backside": true, "drag_x_offset": 497, "drag_y_offset": 74.8125 }, "version": 1, "shared_widgets": [ { "semantic": { "type": "number", "operator": "=", "numerator": "2", "denominator": "1", "format": "improper_fraction" }, "view": { "frontside_width": 76, "frontside_height": 55, "frontside_left": 208.3125, "frontside_top": 52.3125, "backside_width": 779, "backside_height": 351, "backside_left": 13.59375, "backside_top": 121.59375, "advanced_settings_open": true, "backside_geometry": { "x_scale": 1, "y_scale": 1, "original_width": 550, "original_height": 200 }, "saved_width": 76, "saved_height": 55, "backside": false }, "version": 1 } ] }

Function birds

You can use function birds to do many other mathematical operations on numbers (e.g. modulo, power, trigonometric functions).

If you try to use a function bird to work out two to the millionth power then expect your browser to freeze for a minute or so as it computes a very large number. This number is over 300,000 digits long. With a normal font it would go on for 79 pages. You can click on the numerator area on the backside of the number, type control-a to select all the digits, control-c to copy them, and then paste (control-v) into some other document to see all the digits.

How do ToonTalk numbers compare to numbers in other programming languages?

ToonTalk is nearly unique in using exact arithmetic that is limited only by the amount of memory your browser can use. Other programming language rely upon floating point numbers which, while faster and require less memory, are approximate and limited.

For more details read The Child-Engineering of Arithmetic in ToonTalk.

Go to ToonTalk manual home page