>>>READER-TO-READER QUESTIONS AND ANSWERS
output of the inverter, which operates continuously when
the power switch is on. The DC supply voltage powers the
inverter and keeps the battery charged. Only when the
utility AC power fails is the battery under load as it supplies
power to the inverter. If the UPS power switch is off,
the inverter is turned off, and the power supply remains
energized and keeps the battery charged as long as the
UPS is plugged in.
Harbor City, CA
[#3073 - March 2007]
I am working with the very old, MS-Basic Interpreter. It
is limited to 16 digits in double-precision mode. If I try to
multiply two 15-digit numbers, it slips into "Exponential
Notation" mode: example 2.43E+06. Thus, a 15-digit number
TIMES another 15-digit number would have a 30-digit
product. Is there a way to convert — in MS-Basic — this
"Exponential Notation" into all 30 digits?
To do the math in MS Basic with huge numbers, you
need to know at least how to do the math on a blackboard,
especially the multiplication and long division. Scientific or
exponential notation or "floating point" does not calculate
very many digits of large numbers, mainly because they
aren't often needed for most practical uses. So you must
program subroutines to do the arithmetic at least the blackboard way, or look up algorithms (but it may be hard to find
them in Basic). Here are a few ideas to start:
1. You can use strings to hold numbers up to 255 digits
and access each digit using the MID$ command.
20 GOSUB 3000:REM MULTIPLY
30 PRINT C$
2. You can use arrays to store numbers, but it’s slower
and wastes memory, and makes it harder to enter numbers.
Example: For up to 100 digit numbers, one array
element per digit defined as:
10 DIM A(100),B(100),C(100),D(100)
3. You can reserve a large area of memory as a virtual
blackboard using the CLEAR command, and store, access,
and process digits of numbers using POKE and PEEK within
the reserved space.
That way, you can easily (but slowly) work with many
thousands of digits. It's recommended to compile or
assemble the finished subroutines into machine language
for speed, especially when this method is used. Handling
decimal points will be an extra challenge, but it won't make
much difference whether you use remainders or decimal
points in division. It depends on whether you learned them
in school. Here is an example of addition in the method
using arrays, without handling decimal points:
1000 REM ADD A() TO B(B) AND PUT INTO C()
1010 X=0:C=0:REM X is digit number and C is carry
1020 C(X)=A(X)+B(X)+C:IF C(X)<10 THEN 1040:REM NO CARRY
1030 C=1:C(X)=C(X)-10:X=X+1:GOTO 1020:REM CARRY
1040 C=0:X=X+1:IF X<=100 THEN 1020:REM DO 100 DIGITS
1050 RETURN:REM IT'S DONE
It is possible for this to overflow if the answer is too
high. And it's necessary to fill the arrays with zeroes before
putting new numbers into them. Also, the numbers should
be printed out starting at the highest digit which is not a
zero, with the C(1) and C(0) being the last digits printed.
Working with strings makes the most sense in general
but the example would be more confusing involving
MID$,ASC,VAL,STR$,LEN,LEFT$,RIGHT$,CHR$, etc. The
POKE and PEEK method is the most powerful in number
size and works similar to the array method.
[#5073 - May 2007]
Ineed a source for 365 variable capacitors which
RadioShack used to sell as catalog number 272-1431 and
used to be incorporated in their Science Fair kits — I've tried
eBay but the sellers want too much for it!.
Alas, RadioShack has discontinued the variable capacitor, but one can find a substitute from Graymark
International. They have an AM Radio kit, Model 536, that
uses a similar capacitor, it is a dual section, ant & osc, but
same size. Their P/N is 62714; cost was around $2.
This will require a tuning knob, not included, their P/N
62705; another quarter or so. I used the kit in teaching a
radio class, it is a REAL good training tool. Good radio, too.
Scott City, KS