Define a primitive data type: Difference between revisions

Content added Content deleted
(Changed low bound to 1 to conform to the task requirement.)
Line 541: Line 541:
Integer => x,
Integer => x,
TinyInt => x.toInteger(),
TinyInt => x.toInteger(),
_ => throw "Type \"\(x.getType():name)\" is not supported by this operation."
_ => throw "Type \"\(x.getType()::name)\" is not supported by this operation."
}
}
}
}
Line 553: Line 553:
}
}
static func TinyInt.TinyInt(i) {
func TinyInt.TinyInt(i) cons {
new(boundsCheck(Integer(i)))
boundsCheck(Integer(i))
}
}
func TinyInt.toString() {
func TinyInt.toString() decons {
valueof(this).toString()
this.toString()
}
}
func TinyInt.toInteger() {
func TinyInt.toInteger() decons {
valueof(this)
this
}
}
func TinyInt + (other) {
func TinyInt + (other) decons {
const z = valueof(this) + getInteger(other)
let z = this + getInteger(other)
TinyInt(z)
TinyInt(z)
}
}
func TinyInt * (other) {
func TinyInt * (other) decons {
const z = valueof(this) * getInteger(other)
let z = this * getInteger(other)
TinyInt(z)
TinyInt(z)
}
}
func TinyInt - (other) {
func TinyInt - (other) decons {
const z = valueof(this) - getInteger(other)
let z = this - getInteger(other)
TinyInt(z)
TinyInt(z)
}
}
func TinyInt / (other) {
func TinyInt / (other) decons {
const z = valueof(this) / getInteger(other)
let z = this / getInteger(other)
TinyInt(z)
TinyInt(z)
}</lang>
}</lang>