POWER-root

Developer(s): Stan Livingston
Date: 1985
Type: Program
Platform(s): TS 2068

Works out a power or a root of a number, including odd powers and odd roots of negative numbers, and reports an illegal argument for an even root of a negative number.

RUN it, enter the number, type p for a power or r for a root (lower case), then enter the power or the root. Fractional powers of negative numbers are not real numbers; the program prints a value for them anyway.

Published in LISTing October 1985 (POWER-root), and printed again in June-August 1989.

Related Articles

Stanley W. Livingston

Image Gallery

Source Code

  10 REM POWER-root
  20 LET c=1
  30 INPUT "INPUT ARGUMENT ";a
  40 LET h=a
  50 INPUT "POWER OR root? ";b$
  60 IF b$="p" THEN LET b$="POWER "
  70 INPUT "VALUE OF POWER OR root ";d
  80 LET g=d
  90 LET e=ABS d
 100 LET f=INT e
 110 IF a<0 AND b$="r" AND (f/2)=INT (f/2) THEN PRINT "ILLEGAL ARGUMENT": STOP
 120 IF b$="r" THEN LET d=1/d
 130 IF b$="r" THEN LET b$="root "
 140 IF h<0 AND (f/2)<>(INT (f/2)) THEN LET c=-1
 150 LET a=ABS a
 160 PRINT g;" "; b$;h;" = ";a↑d*c

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.