App Inventor Computes With Big Integers

I recently wrote that App Inventor represents its numbers in floating-point. I’ve since discovered something curious about integers. When typed into math blocks, they are represented in floating-point; but when generated through calculations, they are represented as arbitrary-precision integers — big integers.

These blocks compute 2234112:
App Inventor Blocks That Compute 2234112

They give this 376-digit answer:
App Output For Computation of 2234112

The answer is correct, as verified by PARI/GP:


The only way App Inventor could have done this correctly is by using big integers.

On the other hand, when I paste that number into a number block, App Inventor sets it to infinity:
The Value of 2234112 Pasted Into a Number Block Becomes Infinity

It’s too big for double-precision floating-point.



  1. Well, there’s number blocks and text blocks. What I’m going to try is to see if text blocks can be used in math.

  2. @Frank,

    If you wrap an integer argument of a math block in a text block it is treated as a big integer; check it out:


    Emulator output:

    (That is the correct answer.)

    This is a good way to work with big integer arguments. Thanks for the suggestion.

  3. I thought you said it wouldn’t work in the other discussion. But it does! That makes my life MUCH easier. Thanks!

  4. Oh! An intiger, not a decimal. O.K., It’s back to being . . . well, not dificul, but teadious. O.K., thanks!

  5. Hi Rick,
    I’m building an App Inventor class for grade 8s, and I’m putting together some example apps for them to build (following help videos I’ll make). One app I thought they’d like is a calculator. But I’m discovering issues in displaying large numbers, and for catching errors (like squaring a value until it is too big and the app freezes).

    You seem to understand these number issue (unlike me); could you point me in the right direction for formatting large numbers into scientific notation for a fixed display size (say 16 characters)? Sometimes the numbers are displayed in SI, but sometimes its a huge integer that wraps.

    Thank you!

  6. Never mind, Rick! I used your 2234^112 number to test against, and I avoid the app crashing. Too bad there isn’t a built-in test or constant. Thank goodness you have the info!

Comments are closed.

Copyright © 2008-2024 Exploring Binary

Privacy policy

Powered by WordPress