FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

MATHEMATICS

Use huge numbers


OK. Considering the length of time I've had FB, I can't say I have any familiarity with it above and beyond what I already possessed, years ago, attempting little mathematical curios on an HP75C. The following is an example of my present sad state of affairs:

00001 INPUT i&
00002 IF MOUSE(_down) THEN STOP ELSE j&=i&
00003 DO
00004 i&=i&-1:k#=j&
00005 IF j&/2=k#/2 THEN j&=i&-j&/2 ELSE j&=i&+(j&+1)/2
00006 UNTIL j&>2*i&-4 OR MOUSE(_down)
00007 IF i&=1 THEN i&=3 ELSE i&=i&+j&-1
00008 PRINT i&:GOTO 2

The program is designed to accept a positive integer and generate an integer sequence that appears to approach infinity (with the exception of inputs: 1, 4, 8, 14, 171, 813, and 985). The only reason for non-integer k# is so that I can do the even-odd parity check in line 5. Whatever its faults, it does what I want it to do, but I *would* like to extend the program's capabilty in two ways...

First, I would like to explore numbers that extend beyond the long-integer range, i.e. numbers possibly as big as 10^11. How do I set this up?

Secondly, I'd like to write the program's generated number-sequence to a text-file, rather than the window - as is - out of which I can't even copy/paste. I know I have to use the WRITE statement but I'm dumbfounded by its syntax. Anybody?

Hans


Double-precision floats (e.g., x#) seem to have about 12 digits of precision, so you could use those.

You might do better to use the PRINT# statement, which has a syntax essentially identical to the PRINT statement. WRITE is more appropriate for binary files, while PRINT# is more appropriate for text files. If you have opened a file and given it ID #1, then you can write to it (for example) as follows:

PRINT#1, x#

It also seems that if a double-precision number that is more than 11 digits long, FB likes to print it in scientific notation (e.g. "1.23456789012E11"). If you plan to use numbers that big, and you want them to look like "normal" integers in the text file, consider using PRINT USING. For example:

PRINT#1 USING "############"; x#

Rick