|
|
6.123 ScaledDecimal
- Defined in namespace Smalltalk
- Category: Kernel-Numbers
- ScaledDecimal provides a numeric representation of fixed point decimal
numbers able to accurately represent decimal fractions. It supports
unbounded precision, with no limit to the number of digits before and
after the decimal point.
6.123.1 ScaledDecimal class: constants
- initialize
- Initialize the receiver's class variables
6.123.2 ScaledDecimal class: instance creation
- newFromNumber: aNumber scale: scale
- Answer a new instance of ScaledDecimal, representing a decimal fraction with a decimal representation considered valid up to the scale-th digit.
6.123.3 ScaledDecimal: arithmetic
- * aNumber
- Multiply two numbers and answer the result.
- + aNumber
- Sum two numbers and answer the result.
- - aNumber
- Subtract aNumber from the receiver and answer the result.
- / aNumber
- Divide two numbers and answer the result.
- // aNumber
- Answer the integer quotient after dividing the receiver by aNumber with truncation towards negative infinity.
- \\ aNumber
- Answer the remainder after integer division the receiver by aNumber with truncation towards negative infinity.
6.123.4 ScaledDecimal: coercion
- asFloat
- Answer the receiver, converted to a Float
- asFraction
- Answer the receiver, converted to a Fraction
- coerce: aNumber
- Answer aNumber, converted to a ScaledDecimal with the same scale as the receiver.
- fractionPart
- Answer the fractional part of the receiver.
- generality
- Return the receiver's generality
- integerPart
- Answer the fractional part of the receiver.
- truncated
- Answer the receiver, converted to an Integer and truncated towards -infinity.
6.123.5 ScaledDecimal: comparing
- < aNumber
- Answer whether the receiver is less than arg.
- <= aNumber
- Answer whether the receiver is less than or equal to arg.
- = arg
- Answer whether the receiver is equal to arg.
- > aNumber
- Answer whether the receiver is greater than arg.
- >= aNumber
- Answer whether the receiver is greater than or equal to arg.
- hash
- Answer an hash value for the receiver.
- ~= arg
- Answer whether the receiver is not equal arg.
6.123.6 ScaledDecimal: constants
- one
- Answer the receiver's representation of one.
- zero
- Answer the receiver's representation of zero.
6.123.7 ScaledDecimal: printing
- displayOn: aStream
- Print a representation of the receiver on aStream, intended to be directed to a user. In this particular case, the `scale' part of the #printString is not emitted.
- printOn: aStream
- Print a representation of the receiver on aStream.
6.123.8 ScaledDecimal: storing
- storeOn: aStream
- Print Smalltalk code that compiles to the receiver on aStream.
|