Skip to content

Commit

Permalink
v1.0.0 signatures (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbressler13 authored Jan 23, 2024
1 parent e0c5bef commit e2f2522
Show file tree
Hide file tree
Showing 7 changed files with 429 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ package xyz.lbres.exactnumbers.exactfraction
* [ArithmeticException] for ExactFraction overflow.
* Has field for string representation of value that caused overflow
*/
class ExactFractionOverflowException() : ArithmeticException() {
override var message: String? = null
var overflowValue: String? = null
class ExactFractionOverflowException private constructor(message: String?, overflowValue: String?, noArgs: Boolean) : ArithmeticException() {
override val message: String?
val overflowValue: String?

constructor (message: String) : this() {
init {
this.message = message
}

constructor (message: String, overflowValue: String) : this(message) {
this.overflowValue = overflowValue
}

constructor() : this(null, null, true)

constructor(message: String) : this(message, null, false)

constructor(message: String, overflowValue: String) : this(message, overflowValue, false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@ package xyz.lbres.exactnumbers.exceptions
/**
* ArithmeticException for overflows when casting numbers
*/
class CastingOverflowException() : ArithmeticException() {
override var message: String? = null
var overflowValue: Any? = null
class CastingOverflowException private constructor(
baseType: String,
targetType: String,
valueString: String,
overflowValue: Any?,
noArgs: Boolean
) : ArithmeticException() {
override val message: String?
val overflowValue: Any?

init {
if (noArgs) {
this.message = null
this.overflowValue = null
} else {
this.message = "Overflow casting value $valueString of type $baseType to $targetType"
this.overflowValue = overflowValue
}
}

constructor() : this("", "", "", null, true)

/**
* @param baseType [String]: name of type being cast from
* @param targetType [String]: name of type being cast to
* @param valueString [String]: string to display for value that caused overflow
* @param overflowValue [Any]?: number that caused overflow. Optional, defaults to `null`
*/
constructor (baseType: String, targetType: String, valueString: String, overflowValue: Any? = null) : this() {
this.message = "Overflow casting value $valueString of type $baseType to $targetType"
this.overflowValue = overflowValue
}
constructor (baseType: String, targetType: String, valueString: String, overflowValue: Any? = null) :
this(baseType, targetType, valueString, overflowValue, false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ sealed class Term : Number() {
abstract val coefficient: ExactFraction
abstract val factors: List<IrrationalNumber<*>>
abstract val logs: List<Log>
abstract val squareRoots: List<Sqrt>
abstract val pis: List<Pi>
abstract val piCount: Int
abstract val squareRoots: List<Sqrt>

abstract operator fun unaryMinus(): Term
abstract operator fun unaryPlus(): Term
Expand Down
1 change: 0 additions & 1 deletion signatures/v1.0.0/changes.md

This file was deleted.

130 changes: 130 additions & 0 deletions signatures/v1.0.0/updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
*v0.1.1 → v1.0.0*

### xyz.lbres.exactnumbers.exactfraction

**ExactFraction**
```kotlin
class ExactFraction

DEL var numerator: BigInteger
ADD val numerator: BigInteger

DEL var denominator: BigInteger
ADD val denominator: BigInteger

ADD fun isWholeNumber(): Boolean
ADD fun pow(other: BigInteger): ExactFraction
ADD fun pow(other: Long): ExactFraction
ADD fun pow(other: Int): ExactFraction
ADD fun roundToWhole(roundingMode: RoundingMode): ExactFraction
```

**ExactFractionOverflowException**
```kotlin
DEL var message: String?
ADD val message: String?

DEL var overflowValue: String?
ADD val overflowValue: String?
```

**Other**
```kotlin
DEL fun checkIsEFString(s: String): Boolean
```

### xyz.lbres.exactnumbers.exceptions

**CastingOverflowException**
```kotlin
ADD class CastingOverflowException: ArithmeticException()
```

### xyz.lbres.exactnumbers.expressions.term

**Note**: xyz.lbres.expressions.term → xyz.lbres.exactnumbers.expressions.term

**Term**
```kotlin
ADD class Term
DEL class Term: Number()

ADD val factors: List<IrrationalNumber<*>>
ADD val logs: List<Log>
ADD val pis: List<Pi>
ADD val piCount: Int
ADD val squareRoots: List<Sqrt>

ADD fun getFactorsByType(irrationalType: String): List<IrrationalNumber<*>>

DEL fun getLogs(): List<Log>
ADD @Deprecated fun getLogs(): List<Log>

DEL fun getPiCount(): Int
ADD @Deprecated fun getPiCount(): Int

DEL fun getSquareRoots(): List<Sqrt>
ADD @Deprecated fun getSquareRoots(): List<Sqrt>
```

**Term.Companion**
```kotlin
object Term.Companion

ADD fun fromValues(coefficient: ExactFraction, factors: List<IrrationalNumber<*>>): Term
```

### xyz.lbres.exactnumbers.irrationals

**IrrationalNumber**
```kotlin
ADD abstract class IrrationalNumber<T : IrrationalNumber<T>>: Comparable<T>, Number()
```

### xyz.lbres.exactnumbers.irrationals.log

**Log**
```kotlin
DEL class Log: Comparable<Log>, Irrational
ADD class Log: IrrationalNumber<Log>()

DEL Log(argument: BigInteger, isDivided: Boolean)
DEL Log(argument: BigInteger, base: Int, isDivided: Boolean)
DEL Log(argument: ExactFraction, isDivided: Boolean)
DEL Log(argument: ExactFraction, base: Int, isDivided: Boolean)
DEL Log(argument: Int, isDivided: Boolean)
DEL Log(argument: Int, base: Int, isDivided: Boolean)
DEL Log(argument: Long, isDivided: Boolean)
DEL Log(argument: Long, base: Int, isDivided: Boolean)
```

### xyz.lbres.exactnumbers.irrationals.pi

**Pi**
```kotlin
DEL class Pi: Irrational
ADD class Pi: IrrationalNumber<Pi>()

DEL Pi(isDivided: Boolean): Pi

ADD fun toPlainString(): String
```

### xyz.lbres.exactnumbers.irrationals.pi

**Sqrt**
```kotlin
DEL class Sqrt: Comparable<Sqrt>, Irrational
ADD class Sqrt: IrrationalNumber<Sqrt>()

ADD fun toPlainString(): String
```

### xyz.lbres.expression.term

**Note**: xyz.lbres.expressions.term → xyz.lbres.exactnumbers.expressions.term

```kotlin
DEL class Term
ADD @Deprecated typealias Term = xyz.lbres.exactnumbers.expressions.term.Term
```
Loading

0 comments on commit e2f2522

Please sign in to comment.