BigInt implementation #81
@ -1,6 +1,8 @@
|
||||
|
||||
package scientifik.kmath.operations
|
||||
|
||||
import kotlin.math.log2
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
import kotlin.math.sign
|
||||
|
||||
/*
|
||||
@ -27,7 +29,6 @@ object KBigIntegerRing: Ring<KBigInteger> {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
operator fun String.unaryPlus(): KBigInteger = KBigInteger(this)!!
|
||||
|
||||
operator fun String.unaryMinus(): KBigInteger = -KBigInteger(this)!!
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +162,7 @@ class KBigInteger(sign: Int = 0, magnitude: Magnitude = Magnitude(0)):
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return result
|
||||
}
|
||||
|
||||
internal fun divideMagnitudeByUInt(mag: Magnitude, x: UInt): Magnitude {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
private fun divideMagnitudeByUInt(mag: Magnitude, x: UInt): Magnitude {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val resultLength: Int = mag.size
|
||||
val result = Magnitude(resultLength)
|
||||
var carry: ULong = 0UL
|
||||
@ -174,39 +175,6 @@ class KBigInteger(sign: Int = 0, magnitude: Magnitude = Magnitude(0)):
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return result
|
||||
}
|
||||
|
||||
internal fun divideMagnitudes(mag1_: Magnitude, mag2: Magnitude): Magnitude {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val mag1 = ULongArray(mag1_.size) { mag1_[it].toULong() }
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val resultLength: Int = mag1.size - mag2.size + 1
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val result = LongArray(resultLength)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (i in mag1.size - 1 downTo mag2.size - 1) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val div: ULong = mag1[i] / mag2[mag2.size - 1]
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
result[i - mag2.size + 1] = div.toLong()
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (j in mag2.indices) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
mag1[i - j] -= mag2[mag2.size - 1 - j] * div
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (i > 0) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
mag1[i - 1] += (mag1[i] shl BASE_SIZE)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val normalizedResult = Magnitude(resultLength)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
var carry = 0L
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (i in result.indices) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
result[i] += carry
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (result[i] < 0L) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
normalizedResult[i] = (result[i] + (BASE + 1UL).toLong()).toUInt()
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
carry = -1
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
} else {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
normalizedResult[i] = result[i].toUInt()
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
carry = 0
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return normalizedResult
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
|
||||
override fun compareTo(other: KBigInteger): Int {
|
||||
@ -287,12 +255,100 @@ class KBigInteger(sign: Int = 0, magnitude: Magnitude = Magnitude(0)):
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return KBigInteger(this.sign * other.sign, divideMagnitudeByUInt(this.magnitude, kotlin.math.abs(other).toUInt()))
|
||||
}
|
||||
|
||||
operator fun div(other: KBigInteger): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return when {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
this < other -> ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
this == other -> ONE
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
else -> KBigInteger(this.sign * other.sign, divideMagnitudes(this.magnitude, other.magnitude))
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
private fun division(other: KBigInteger): Pair<KBigInteger, KBigInteger> {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
// Long division algorithm:
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
// https://en.wikipedia.org/wiki/Division_algorithm#Integer_division_(unsigned)_with_remainder
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
// TODO: Implement more effective algorithm
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
var q: KBigInteger = ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
var r: KBigInteger = ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val bitSize = (BASE_SIZE * (this.magnitude.size - 1) + log2(this.magnitude.last().toFloat() + 1)).toInt()
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (i in bitSize downTo 0) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
r = r shl 1
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
r = r or ((abs(this) shr i) and ONE)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (r >= abs(other)) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
r -= abs(other)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
q += (ONE shl i)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return Pair(KBigInteger(this.sign * other.sign, q.magnitude), r)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
operator fun div(other: KBigInteger): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return this.division(other).first
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
infix fun shl(i: Int): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (this == ZERO) return ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (i == 0) return this
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val fullShifts = i / BASE_SIZE + 1
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val relShift = i % BASE_SIZE
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val shiftLeft = {x: UInt -> if (relShift >= 32) 0U else x shl relShift}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val shiftRight = {x: UInt -> if (BASE_SIZE - relShift >= 32) 0U else x shr (BASE_SIZE - relShift)}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val newMagnitude: Magnitude = Magnitude(this.magnitude.size + fullShifts)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (j in this.magnitude.indices) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[j + fullShifts - 1] = shiftLeft(this.magnitude[j])
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (j != 0) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[j + fullShifts - 1] = newMagnitude[j + fullShifts - 1] or shiftRight(this.magnitude[j - 1])
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[this.magnitude.size + fullShifts - 1] = shiftRight(this.magnitude.last())
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return KBigInteger(this.sign, newMagnitude)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
infix fun shr(i: Int): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (this == ZERO) return ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (i == 0) return this
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val fullShifts = i / BASE_SIZE
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val relShift = i % BASE_SIZE
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val shiftRight = {x: UInt -> if (relShift >= 32) 0U else x shr relShift}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val shiftLeft = {x: UInt -> if (BASE_SIZE - relShift >= 32) 0U else x shl (BASE_SIZE - relShift)}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (this.magnitude.size - fullShifts <= 0) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return ZERO
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val newMagnitude: Magnitude = Magnitude(this.magnitude.size - fullShifts)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (j in fullShifts until this.magnitude.size) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[j - fullShifts] = shiftRight(this.magnitude[j])
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (j != this.magnitude.size - 1) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[j - fullShifts] = newMagnitude[j - fullShifts] or shiftLeft(this.magnitude[j + 1])
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return KBigInteger(this.sign, newMagnitude)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
infix fun or(other: KBigInteger): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (this == ZERO) return other;
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (other == ZERO) return this;
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val resSize = max(this.magnitude.size, other.magnitude.size)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val newMagnitude: Magnitude = Magnitude(resSize)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (i in 0 until resSize) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (i < this.magnitude.size) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[i] = newMagnitude[i] or this.magnitude[i]
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if (i < other.magnitude.size) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[i] = newMagnitude[i] or other.magnitude[i]
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return KBigInteger(1, newMagnitude)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
infix fun and(other: KBigInteger): KBigInteger {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
if ((this == ZERO) or (other == ZERO)) return ZERO;
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val resSize = min(this.magnitude.size, other.magnitude.size)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
val newMagnitude: Magnitude = Magnitude(resSize)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
for (i in 0 until resSize) {
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
newMagnitude[i] = this.magnitude[i] and other.magnitude[i]
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
return KBigInteger(1, newMagnitude)
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
||||
}
|
||||
|
||||
operator fun rem(other: Int): Int {
|
||||
|
||||
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Why use whole Why use whole `Int` for simple three way flag? Could it be replaced by boolean? Enum?
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders. Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class Companion should be last declaration in the class
Companion should be last declaration in the class Companion should be last declaration in the class
Also all internal values must be marked as private Also all internal values must be marked as private
Also all internal values must be marked as private Also all internal values must be marked as private
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
should be virtual if it is not performance-critical should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members. It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Refactor to String.toBigInteger() Refactor to String.toBigInteger()
Now using Byte for that Now using Byte for that
Now using Byte for that Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement? Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html) This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
|
@ -244,6 +244,62 @@ class KBigIntegerOperationsTest {
|
||||
assertEquals(prod, res)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shr_20() {
|
||||
val x = KBigInteger(20)
|
||||
assertEquals(KBigInteger(10), x shr 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shl_20() {
|
||||
val x = KBigInteger(20)
|
||||
assertEquals(KBigInteger(40), x shl 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shl_1_0() {
|
||||
assertEquals(KBigInteger.ONE, KBigInteger.ONE shl 0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shl_1_32() {
|
||||
assertEquals(KBigInteger(0x100000000UL), KBigInteger.ONE shl 32)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shl_1_33() {
|
||||
assertEquals(KBigInteger(0x200000000UL), KBigInteger.ONE shl 33)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shr_1_33_33() {
|
||||
assertEquals(KBigInteger.ONE, (KBigInteger.ONE shl 33) shr 33)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_shr_1_32() {
|
||||
assertEquals(KBigInteger.ZERO, KBigInteger.ONE shr 32)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_and_123_456() {
|
||||
val x = KBigInteger(123)
|
||||
val y = KBigInteger(456)
|
||||
assertEquals(KBigInteger(72), x and y)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_or_123_456() {
|
||||
val x = KBigInteger(123)
|
||||
val y = KBigInteger(456)
|
||||
assertEquals(KBigInteger(507), x or y)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_asd() {
|
||||
assertEquals(KBigInteger.ONE, KBigInteger.ZERO or ((KBigInteger(20) shr 4) and KBigInteger.ONE))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_square_0x11223344U_0xad2ffffdU_0x17eU() {
|
||||
val num = KBigInteger(-1, uintArrayOf(0x11223344U, 0xad2ffffdU, 0x17eU ))
|
||||
@ -307,6 +363,12 @@ class KBigIntegerOperationsTest {
|
||||
assertEquals(div, res)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBigDivision_0xfffffffeabcdef01UL_0xfffffffeabc() {
|
||||
val res = KBigInteger(0xfffffffeabcdef01UL) / KBigInteger(0xfffffffeabc)
|
||||
assertEquals(res, KBigInteger(0x100000))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBigDivision_0xfffffffe00000001_0xffffffff() {
|
||||
val x = KBigInteger(0xfffffffe00000001UL)
|
||||
@ -379,7 +441,7 @@ class KBigIntegerOperationsTest {
|
||||
val exp = KBigInteger(2)
|
||||
val mod = KBigInteger(0xfffffffeabcUL)
|
||||
|
||||
val res = KBigInteger(0x6deec7895faUL)
|
||||
val res = KBigInteger(0xc2253cde01)
|
||||
|
||||
return assertEquals(res, x.modPow(exp, mod))
|
||||
}
|
||||
@ -434,26 +496,9 @@ class KBigIntegerConversionsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.ExperimentalUnsignedTypes
|
||||
class DivisionTests {
|
||||
// TODO
|
||||
@Test
|
||||
fun test_0xfffffffeabcdef01UL_0xfffffffeabc() {
|
||||
val res = KBigInteger(0xfffffffeabcdef01UL) / KBigInteger(0xfffffffeabc)
|
||||
assertEquals(res, KBigInteger(0x100000))
|
||||
|
||||
}
|
||||
|
||||
// println(KBigInteger(+1, uintArrayOf(1000U, 1000U, 1000U)) / KBigInteger(0xfffffffeabc) )
|
||||
// >>> hex((1000 + 1000*2**32 + 1000*2**64)/ 0xfffffffeabc) == 0x3e800000L
|
||||
// println(KBigInteger(+1, KBigInteger.divideMagnitudeByUInt(uintArrayOf(1000U, 1000U, 1000U),456789U)))
|
||||
// 0x8f789719813969L
|
||||
|
||||
}
|
||||
|
||||
class KBigIntegerRingTest {
|
||||
@Test
|
||||
fun testSum() {
|
||||
fun testKBigIntegerRingSum() {
|
||||
val res = KBigIntegerRing {
|
||||
KBigInteger(1_000L) * KBigInteger(1_000L)
|
||||
}
|
||||
@ -461,7 +506,7 @@ class KBigIntegerRingTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_sum_100_000_000__100_000_000() {
|
||||
fun testKBigIntegerRingSum_100_000_000__100_000_000() {
|
||||
KBigIntegerRing {
|
||||
val sum = +"100_000_000" + +"100_000_000"
|
||||
assertEquals(sum, KBigInteger("200_000_000"))
|
||||
@ -476,5 +521,23 @@ class KBigIntegerRingTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_div_big_1() {
|
||||
KBigIntegerRing {
|
||||
val res = +"1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000" /
|
||||
+"555_000_444_000_333_000_222_000_111_000_999_001"
|
||||
assertEquals(res, +"1801800360360432432518919022699")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_rem_big_1() {
|
||||
KBigIntegerRing {
|
||||
val res = +"1_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000_000" %
|
||||
+"555_000_444_000_333_000_222_000_111_000_999_001"
|
||||
assertEquals(res, +"324121220440768000291647788404676301")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Why use whole
Int
for simple three way flag? Could it be replaced by boolean? Enum?Why use whole
Int
for simple three way flag? Could it be replaced by boolean? Enum?Move to private constructor and move parameter checks to auxiliary builders.
Move to private constructor and move parameter checks to auxiliary builders.
Companion should be last declaration in the class
Companion should be last declaration in the class
Also all internal values must be marked as private
Also all internal values must be marked as private
should be virtual if it is not performance-critical
should be virtual if it is not performance-critical
It does not make sense to make it RingElement since all operations are already class members.
It does not make sense to make it RingElement since all operations are already class members.
Refactor to String.toBigInteger()
Refactor to String.toBigInteger()
Now using Byte for that
Now using Byte for that
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
Even byte is wasteful. Especially considering that my eat whole word due to alignment. Why not use 2-complement?
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)
This may be a good idea, but I suspect (performance) problems with 2-complement will appear when we try to operate with numbers of different length. At least the classical Java BigInt implementation stores magnitude and signum separately (http://developer.classpath.org/doc/java/math/BigInteger-source.html)