HP Forums

Full Version: Convert number to scientific notation
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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.
Reference URL's