St V/Mac Number fix 
Author Message
 St V/Mac Number fix

"A little while ago there was a discussion in this group about errors with
negative numbers when using the printFraction: method in Smalltalk V/Mac.
I was just browsing through an old issue of Scoop when I saw a fix for it
from Digitalk.  I remember adding this at the time (to v1.1) but when v1.2
came out I assumed that this was fixed. Evidently not.  So here it is again.
Thanks to John Nagle for bringing this back to my attention.

Alun ap Rhisiart."

Smalltalk at: #Number ifAbsent: [
Magnitude subclass: #Number
  instanceVariableNames: ''
  classVariableNames: ''
  poolDictionaries: '']. !

!Number class methods ! !

!Number methods !

printFraction: numberFractionDigits
    "Answer a string, the ASCII representation of the
     receiver truncated to numberFractionDigits decimal
     places. Changed according to SCOOP III-2"
   | stream fraction integer |

    numberFractionDigits < 0
        ifTrue: [self error: 'Negative digit count'].
    stream := WriteStream on: (String new: 16).
    integer := self truncated.
    (self > -1) & (self < 0)
        ifTrue: [ stream show: '-0']
        ifFalse: [ integer printOn: stream].
    stream nextPut: $..
    fraction := (self - integer) abs.
    integer := 0.
    numberFractionDigits timesRepeat: [
        fraction := (fraction - integer) * 10.
        (integer := fraction // 1) printOn: stream].
    ^ stream contents!

roundTo: aNumber
    "Answer the receiver rounded to the nearest multiple of
     aNumber. Changed according to SCOOP VIII/2 1990"

    self negative
        ifTrue: [^self - (aNumber/2) truncateTo: aNumber]
        ifFalse: [ ^self + (aNumber/2) truncateTo: aNumber]! !
--
***********************************
* Alun ap Rhisiart                *    | When I wrote this, only God |
* Animal Behaviour Research Group *    |  and I knew what it meant.  |
* Oxford University               *    | Now, only God knows.        |

***********************************



Wed, 04 Oct 1995 03:04:33 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ST vs Java vs ST vs ....

2. St/V Mac fix

3. St/V Mac fix

4. ST/V Mac Bug Fixes Source

5. Mac programming: ST/V vs. Prograph

6. ST V / MAC & ST V / WIN

7. ST/V versus ST-80 on a Mac II

8. fixed point vs fixed decimal

9. Clock Problem (VA ST vs. Dolphin ST)

10. Comparison: ST-80 vs. ST-V

11. ST-80/OS/2 vs. ST-80/Windows

12. 10 byte float numbers from ST 8 byte numbers

 

 
Powered by phpBB® Forum Software