|
| 1 | +// Copyright 2025 International Digital Economy Academy |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +///| |
| 16 | +/// Calculates the natural logarithm of a double-precision floating-point number. |
| 17 | +/// |
| 18 | +/// Parameters: |
| 19 | +/// |
| 20 | +/// * `self`: The input number. |
| 21 | +/// |
| 22 | +/// Returns the natural logarithm of the input number, with the following special |
| 23 | +/// cases: |
| 24 | +/// |
| 25 | +/// * Returns NaN if the input is NaN or negative |
| 26 | +/// * Returns negative infinity if the input is zero |
| 27 | +/// * Returns the input if it is positive infinity |
| 28 | +/// |
| 29 | +/// Example: |
| 30 | +/// |
| 31 | +/// ```moonbit |
| 32 | +/// test "ln" { |
| 33 | +/// inspect!(2.0.ln(), content="0.6931471805599453") |
| 34 | +/// inspect!(1.0.ln(), content="0") |
| 35 | +/// inspect!((-1.0).ln(), content="NaN") |
| 36 | +/// inspect!(0.0.ln(), content="-Infinity") |
| 37 | +/// } |
| 38 | +/// ``` |
| 39 | +pub fn ln(self : Double) -> Double = "Math" "log" |
| 40 | +
|
| 41 | +///| |
| 42 | +/// Calculates the base-2 logarithm of a double-precision floating-point number. |
| 43 | +/// |
| 44 | +/// Parameters: |
| 45 | +/// |
| 46 | +/// * `x` : A double-precision floating-point number. |
| 47 | +/// |
| 48 | +/// Returns the base-2 logarithm of the input number. |
| 49 | +/// |
| 50 | +/// Example: |
| 51 | +/// |
| 52 | +/// ```moonbit |
| 53 | +/// test "log2" { |
| 54 | +/// inspect!(2.0.log2(), content="1") |
| 55 | +/// inspect!(0.5.log2(), content="-1") |
| 56 | +/// inspect!(3.0.log2(), content="1.584962500721156") |
| 57 | +/// } |
| 58 | +/// ``` |
| 59 | +pub fn log2(self : Double) -> Double = "Math" "log2" |
| 60 | +
|
| 61 | +///| |
| 62 | +/// Calculates the base-10 logarithm of a double-precision floating-point number. |
| 63 | +/// |
| 64 | +/// Parameters: |
| 65 | +/// |
| 66 | +/// * `self` : The double-precision floating-point number to calculate the |
| 67 | +/// logarithm of. |
| 68 | +/// |
| 69 | +/// Returns a double-precision floating-point number representing the base-10 |
| 70 | +/// logarithm of the input. |
| 71 | +/// |
| 72 | +/// Example: |
| 73 | +/// |
| 74 | +/// ```moonbit |
| 75 | +/// test "log10" { |
| 76 | +/// inspect!(1.0.log10(), content="0") |
| 77 | +/// inspect!(10.0.log10(), content="1") |
| 78 | +/// inspect!(100.0.log10(), content="2") |
| 79 | +/// } |
| 80 | +/// ``` |
| 81 | +pub fn log10(self : Double) -> Double = "Math" "log10" |
0 commit comments