Number.to_exponential
Number.to_exponential
Function
Format a number into a scientific notation string.
Syntax
number.to_exponential(digits)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| digits | Int | No | 6 | Number of decimal places; negative numbers are treated as 0. |
Return value
| Type | Description |
|---|---|
| String | Returns a string in scientific notation. |
Example
num = 1234 result = num.to_exponential(2) // Output: 1.23e3 print result
Notes
- The result is a string, not a number.