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
 Liamtoh Resu Member Posts: 122 Joined: May 2021
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;
 « Next Oldest | Next Newest »

 Messages In This Thread Long decimal results instead of scientific notation? - matalog - 06-23-2021, 09:08 PM RE: Long decimal results instead of scientific notation? - rprosperi - 06-23-2021, 09:17 PM RE: Long decimal results instead of scientific notation? - Liamtoh Resu - 06-23-2021, 09:55 PM RE: Long decimal results instead of scientific notation? - Joe Horn - 06-24-2021, 03:33 AM RE: Long decimal results instead of scientific notation? - Liamtoh Resu - 06-24-2021, 01:16 PM RE: Long decimal results instead of scientific notation? - Liamtoh Resu - 06-25-2021 04:09 AM

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