Post Reply 
Long decimal results instead of scientific notation?
06-25-2021, 04:09 AM (This post was last modified: 06-25-2021 05:09 AM by Liamtoh Resu.)
Post: #6
RE: Long decimal results instead of scientific notation?
Take a look at this program.

Type a number, eg. 9.81e-21 on the command line in HOME.

Type PLZ to launch. It will print and return the desire format on to the stack.
You can change the print() statement to msgbox if you want.

There is a variable named sf if you want to change the number of siginificant
figures.

Thanks for the tip about getting input via Ans(1).

edit: This is very alpha software. It seems to work with numbers less
than one. It will not work in CAS mode. Perhaps the second trunc
function should be a Round function. Perhaps this program can
serve as a base for another one. There are limitations when the
exponent is less that -100. Perhap a version that did not depend
on logarithms and exponents would work better.

Code:

cls();
gans();
EXPORT plz()
BEGIN
local a,b,c;
local d1,f,g;
local h,i,k;
local sf;  // significant figures
local z;
sf := 3;
z := "0";
cls();
a := gans();
b := log(a);
c := abs(b);
d1 := trunc(c);
f := b + d1;
g := 10 ^ f;
h := trunc((10^sf) * g);
k := "0.";
for i from 1 to d1
do
k := k + z;
end;
print (k+h);
END;
cls()
begin
print;
end;
gans()
begin
return Ans(1);
end;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Long decimal results instead of scientific notation? - Liamtoh Resu - 06-25-2021 04:09 AM



User(s) browsing this thread: 1 Guest(s)