Welcome to MSDN Blogs Sign in | Join | Help

Bigger than Google: formatting very big numbers in Grids/Browse

An Exabyte is 10^18 bytes. (Exa, Peta, Tera, Giga, Mega) A Googlebyte is 10^100 bytes (1 followed by 100 zeroes). My 8 year old daughter knows that a GoolePlex is a 1 followed by a google zeroes.

 

The code below generates very big numbers by generating powers of 2 and displays them in both a BROWSE and a grid.

For example 2^ 100, or about 10^30 is shown as

 

      1,267,650,600,228,230,000,000,000,000,000

 

The :P option of the BROWSE FIELDS clause works as the InputMask to put in the comma separators  Using such a  mask on large numbers makes them easier to read, but scientific notation is much better for very large numbers.

Observe that each number ends in either a 2,4 6 or 8, and cannot end in 0 because a power of 2 is not divisible by 5 (or 10). After about 10^16 the numbers do end in 0, indicating that the numeric precision is just under 16 decimal digits (a topic for another blog)

 

CREATE CURSOR temp (name c(10),pow10 c(10),value b)

FOR i = 1 TO 350

      INSERT INTO temp VALUES ("2^"+TRANSFORM(i),"10^"+TRANSFORM(LOG10(2^i)),2^i)

ENDFOR

BROWSE FIELDS name,pow10,value:p="999,999,999,999,999,999,999,999,999,999,999,999" NOWAIT

PUBLIC x as form

SKIP -10    && go back 10 records

x=CREATEOBJECT("form")

x.visible=1

x.addobject("gr","grid")

x.gr.visible=1

x.gr.width=x.width

x.gr.column3.InputMask="999,999,999,999,999,999,999,999,999,999,999,999"

 

 

 

73905

Published Wednesday, June 29, 2005 1:07 PM by Calvin_Hsia
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Bigger than Google: formatting very big numbers in Grids/Browse

Wednesday, June 29, 2005 6:35 PM by mabster
Actually, you're talking about a 'googol'. 'Google' is a search engine, not a number.

# re: Bigger than Google: formatting very big numbers in Grids/Browse

Wednesday, June 29, 2005 6:40 PM by Paul Kinlan
isn't it a googol? a google is the sound a baby makes when they are well..... being like a baby :) I suppose that is the best way to describe the sound of the word :)

If it isn't I look quite silly :)

Paul Kinlan

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker