Generate docs for floorDiv and mod and improve docs for div and rem

Refactor operator documentation generation for primitives and unsigned
types so that it is easier to specialize it.

Manually sync docs of numeric types in js-ir stdlib.

 KT-26234
This commit is contained in:
Ilya Gorbunov
2021-03-02 09:54:10 +03:00
parent 50d4979531
commit 7e2c365b79
11 changed files with 899 additions and 191 deletions
+163 -43
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -118,35 +118,59 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
/** Multiplies this value by the other value. */
public operator fun times(other: Double): Double
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Short): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Int): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Long): Long
/** Divides this value by the other value. */
public operator fun div(other: Float): Float
/** Divides this value by the other value. */
public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Double): Double
@@ -334,35 +358,59 @@ public class Short private constructor() : Number(), Comparable<Short> {
/** Multiplies this value by the other value. */
public operator fun times(other: Double): Double
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Short): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Int): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Long): Long
/** Divides this value by the other value. */
public operator fun div(other: Float): Float
/** Divides this value by the other value. */
public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Double): Double
@@ -548,35 +596,59 @@ public class Int private constructor() : Number(), Comparable<Int> {
/** Multiplies this value by the other value. */
public operator fun times(other: Double): Double
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Short): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Int): Int
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Long): Long
/** Divides this value by the other value. */
public operator fun div(other: Float): Float
/** Divides this value by the other value. */
public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Double): Double
@@ -828,22 +900,46 @@ public class Float private constructor() : Number(), Comparable<Float> {
/** Divides this value by the other value. */
public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Byte): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Short): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Int): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Double): Double
@@ -1046,22 +1142,46 @@ public class Double private constructor() : Number(), Comparable<Double> {
/** Divides this value by the other value. */
public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Byte): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Short): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Int): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Float): Double
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Double): Double
+35 -11
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -135,16 +135,16 @@ public class Long internal constructor(
/** Multiplies this value by the other value. */
public inline operator fun times(other: Double): Double = toDouble() * other
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public inline operator fun div(other: Byte): Long = div(other.toLong())
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public inline operator fun div(other: Short): Long = div(other.toLong())
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public inline operator fun div(other: Int): Long = div(other.toLong())
/** Divides this value by the other value. */
/** Divides this value by the other value, truncating the result to an integer that is closer to zero. */
public operator fun div(other: Long): Long = divide(other)
/** Divides this value by the other value. */
@@ -153,27 +153,51 @@ public class Long internal constructor(
/** Divides this value by the other value. */
public inline operator fun div(other: Double): Double = toDouble() / other
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public inline operator fun rem(other: Byte): Long = rem(other.toLong())
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public inline operator fun rem(other: Short): Long = rem(other.toLong())
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public inline operator fun rem(other: Int): Long = rem(other.toLong())
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public operator fun rem(other: Long): Long = modulo(other)
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public inline operator fun rem(other: Float): Float = toFloat() % other
/** Calculates the remainder of dividing this value by the other value. */
/**
* Calculates the remainder of truncating division of this value by the other value.
*
* The result is either zero or has the same sign as the _dividend_ and has the absolute value less than the absolute value of the divisor.
*/
@SinceKotlin("1.1")
public inline operator fun rem(other: Double): Double = toDouble() % other