Post Reply 
Long decimal results instead of scientific notation?
06-23-2021, 09:08 PM
Post: #1
Long decimal results instead of scientific notation?
Is there a way to get the prime to show all possible leading zeroes in CAS (or normal) mode, for example, to show 0.00000000000000000000981 instead of 9.81E-21?

I have it in standard notation mode.
Find all posts by this user
Quote this message in a reply
06-23-2021, 09:17 PM
Post: #2
RE: Long decimal results instead of scientific notation?
I'm no Prime guru, but it seems unlikely, 'cuz what should it show if the number was 1.0E-250? 250 leading zeros?

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
06-23-2021, 09:55 PM
Post: #3
RE: Long decimal results instead of scientific notation?
I would try using the logarithm of the number to create a string of zeroes and padding
the significant numbers to the end.

The log of 9.81e-21 is about -20.00833988260. Use the absolute value of the
integer. Create a loop to make the zero padded string. Pad the string with 981.

There may be a simpler way.

It is like programming in c where you have to create your own string functions.

I hope this will help get you started.
Find all posts by this user
Quote this message in a reply
06-24-2021, 03:33 AM
Post: #4
RE: Long decimal results instead of scientific notation?
(06-23-2021 09:08 PM)matalog Wrote:  Is there a way to get the prime to show all possible leading zeroes in CAS (or normal) mode, for example, to show 0.00000000000000000000981 instead of 9.81E-21?

I have it in standard notation mode.

Sort of. In CAS, the command:
format(9.81E-21,"f23")
returns the string "0.00000000000000000000981"

A program could be written, I suppose, which would calculate the necessary second argument of format() to obtain the desired output for any given input.

If you're looking for a display mode that automatically displays all leading zeros, sorry, there is no such mode.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
06-24-2021, 01:16 PM
Post: #5
RE: Long decimal results instead of scientific notation?
I came up with a program to print 9.81e-21 in the format you wanted.

It is free form, off the cuff, coding at the keyboard with no optimization.

I hope to recode it later.

Code:

EXPORT numstr01()
BEGIN
local i;
local n,nl,na,nal;
local s,z;
local zi,zl;
local t1,t2,t3;
local t4;
local newline;
print;
newline := "\n";
z :="0";
n := 9.81e-21;
nl := log(n);
// print(n + ", " + nl + ", " + z );
// print(newline);
na := abs(nl);
zl := trunc(na);
// print (na + ", " + zl);
t1 := nl + zl;
t2 := 10^t1;
// print(newline);
// print(t1 + ", " + t2);
t3 := trunc(1000*t2);
// print(t3);
t4 := "0.";
for i from 1 to zl
do
t4 := t4 + z;
end;
print(n+" = " + t4+t3);
END;

Not one for the software engineers but it gets the job done.

Cheers.
Find all posts by this user
Quote this message in a reply
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 




User(s) browsing this thread: