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
+72 -16
View File
@@ -109,55 +109,111 @@ public value class UByte @PublishedApi internal constructor(@PublishedApi intern
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = this.toUInt().div(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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = this.toUInt().rem(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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UByte): UInt = this.toUInt().floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UShort): UInt = this.toUInt().floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UInt): UInt = this.toUInt().floorDiv(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: ULong): ULong = this.toULong().floorDiv(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UByte): UByte = this.toUInt().mod(other.toUInt()).toUByte()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UShort): UShort = this.toUInt().mod(other.toUInt()).toUShort()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UInt): UInt = this.toUInt().mod(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: ULong): ULong = this.toULong().mod(other)
+72 -16
View File
@@ -109,55 +109,111 @@ public value class UInt @PublishedApi internal constructor(@PublishedApi interna
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = uintDivide(this, 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = uintRemainder(this, 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UByte): UInt = this.floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UShort): UInt = this.floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UInt): UInt = div(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: ULong): ULong = this.toULong().floorDiv(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UByte): UByte = this.mod(other.toUInt()).toUByte()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UShort): UShort = this.mod(other.toUInt()).toUShort()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UInt): UInt = rem(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: ULong): ULong = this.toULong().mod(other)
+72 -16
View File
@@ -109,55 +109,111 @@ public value class ULong @PublishedApi internal constructor(@PublishedApi intern
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = ULong(this.data.times(other.data))
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): ULong = this.div(other.toULong())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): ULong = this.div(other.toULong())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): ULong = this.div(other.toULong())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = ulongDivide(this, 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): ULong = this.rem(other.toULong())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): ULong = this.rem(other.toULong())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): ULong = this.rem(other.toULong())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = ulongRemainder(this, other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UByte): ULong = this.floorDiv(other.toULong())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UShort): ULong = this.floorDiv(other.toULong())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UInt): ULong = this.floorDiv(other.toULong())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: ULong): ULong = div(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UByte): UByte = this.mod(other.toULong()).toUByte()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UShort): UShort = this.mod(other.toULong()).toUShort()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UInt): UInt = this.mod(other.toULong()).toUInt()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: ULong): ULong = rem(other)
+72 -16
View File
@@ -109,55 +109,111 @@ public value class UShort @PublishedApi internal constructor(@PublishedApi inter
@kotlin.internal.InlineOnly
public inline operator fun times(other: ULong): ULong = this.toULong().times(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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UByte): UInt = this.toUInt().div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UShort): UInt = this.toUInt().div(other.toUInt())
/** 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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: UInt): UInt = this.toUInt().div(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. */
@kotlin.internal.InlineOnly
public inline operator fun div(other: ULong): ULong = this.toULong().div(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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UByte): UInt = this.toUInt().rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UShort): UInt = this.toUInt().rem(other.toUInt())
/** 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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: UInt): UInt = this.toUInt().rem(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 always less than the divisor.
*/
@kotlin.internal.InlineOnly
public inline operator fun rem(other: ULong): ULong = this.toULong().rem(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UByte): UInt = this.toUInt().floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UShort): UInt = this.toUInt().floorDiv(other.toUInt())
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: UInt): UInt = this.toUInt().floorDiv(other)
/** TODO */
/**
* Divides this value by the other value, flooring the result to an integer that is closer to negative infinity.
*
* For unsigned types, the results of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun floorDiv(other: ULong): ULong = this.toULong().floorDiv(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UByte): UByte = this.toUInt().mod(other.toUInt()).toUByte()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UShort): UShort = this.toUInt().mod(other.toUInt()).toUShort()
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: UInt): UInt = this.toUInt().mod(other)
/** TODO */
/**
* Calculates the remainder of flooring division of this value by the other value.
*
* The result is always less than the divisor.
*
* For unsigned types, the remainders of flooring division and truncating division are the same.
*/
@kotlin.internal.InlineOnly
public inline fun mod(other: ULong): ULong = this.toULong().mod(other)