HP Forums
Convert number to scientific notation - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Convert number to scientific notation (/thread-12588.html)



Convert number to scientific notation - fpicoral - 03-08-2019 04:57 PM

Is there a CAS function or something similar to convert a given number to scientific notation?

Obs: I tried changing the number format to scientific but it only converts to X*E^Y if there is a decimal point in X, i.e., it converts 100.0 to 1.0e^2 but not 100, beside the fact that I only want to use this in some specific situations, so a CAS function would be the best solution.

I tried creating this CAS program using Python but (at least with the PC emulator) it crashes when I try to use the function.

Code:
#cas
def base10(x):
 return "{:.2e}".format(x)
#end



RE: Convert number to scientific notation - Joe Horn - 03-08-2019 05:57 PM

If you mean in a program, then the STRING function might suffice for you. WARNING: You must spell STRING in uppercase letters or it won't work as expected. For example:

STRING(10000,3,0) --> "1e4"

where the 3 argument means "Scientific Display Mode" and the 0 means "displaying zero digits after the decimal point". The built-in Help system contains more info (and lots more options) about the STRING function.