[Pkg] The Trunk: Kernel-nice.848.mcz

commits at source.squeak.org commits at source.squeak.org
Sat May 3 20:48:46 UTC 2014


Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.848.mcz

==================== Summary ====================

Name: Kernel-nice.848
Author: nice
Time: 3 May 2014, 10:47:32.344 pm
UUID: 8e301b04-6b3d-4f42-8292-6d3a8eb34f82
Ancestors: Kernel-eem.847

Now that there is a direct access to Float negativeInfinity, use it.

=============== Diff against Kernel-eem.847 ===============

Item was changed:
  ----- Method: FORTRANNumberParser>>nextNumber (in category 'parsing-public') -----
  nextNumber
  	"main method for reading a number with FORTRAN syntax.
  	This one can read Real and Integer (not complex)"
  
  	| numberOfTrailingZeroInIntegerPart numberOfNonZeroFractionDigits mantissa value numberOfTrailingZeroInFractionPart noInt |
  	base := 10.
  	(self nextMatchAll: 'NaN') ifTrue: [^Float nan].
  	neg := self peekSignIsMinus.
  	(self nextMatchAll: 'Infinity') 
+ 		ifTrue: [^neg ifTrue: [Float negativeInfinity] ifFalse: [Float infinity]].
- 		ifTrue: [^neg ifTrue: [Float infinity negated] ifFalse: [Float infinity]].
  	(noInt := sourceStream peekFor: $.) 
  		ifTrue: 
  			[integerPart := 0.
  			numberOfTrailingZeroInIntegerPart := 0]
  		ifFalse: 
  			[integerPart := self nextUnsignedIntegerBase: base.
  			numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
  	(noInt or: [sourceStream peekFor: $.]) 
  		ifTrue: 
  			[fractionPart := self nextUnsignedIntegerBase: base ifFail: [nil].
  			fractionPart isNil 
  				ifTrue: 
  					[noInt 
  						ifTrue: 
  							["no interger part, no fraction part..."
  							self expected: 'a digit 0 to 9'.
  							^nil].
  					fractionPart := 0]
  				ifFalse: 
  					[numberOfNonZeroFractionDigits := lastNonZero.
  					numberOfTrailingZeroInFractionPart := nDigits - lastNonZero].
  			self readExponent]
  		ifFalse: 
  			[self readExponent ifFalse: [^neg ifTrue: [integerPart negated] ifFalse: [integerPart]].
  			fractionPart := 0].
  	fractionPart isZero 
  		ifTrue: 
  			[mantissa := integerPart // (base raisedTo: numberOfTrailingZeroInIntegerPart).
  			exponent := exponent + numberOfTrailingZeroInIntegerPart]
  		ifFalse: 
  			[mantissa := integerPart * (base raisedTo: numberOfNonZeroFractionDigits) 
  						+ (fractionPart // (base raisedTo: numberOfTrailingZeroInFractionPart)).
  			exponent := exponent - numberOfNonZeroFractionDigits].
  	value := self 
  				makeFloatFromMantissa: mantissa
  				exponent: exponent
  				base: base.
  	^neg ifTrue: [value isZero ifTrue: [Float negativeZero] ifFalse: [value negated]] ifFalse: [value]!

Item was changed:
  ----- Method: Float class>>fromIEEE32Bit: (in category 'instance creation') -----
  fromIEEE32Bit: word
  	"Convert the given 32 bit word (which is supposed to be a positive 32bit value) from a 32bit IEEE floating point representation into an actual Squeak float object (being 64bit wide). Should only be used for conversion in FloatArrays or likewise objects."
  	
  	| sign mantissa exponent newFloat delta |
  	word negative ifTrue: [^ self error:'Cannot deal with negative numbers'].
  	word = 0 ifTrue: [^ Float zero].
  	sign := word bitAnd: 16r80000000.
  	word = sign ifTrue: [^self negativeZero].
  	
  	exponent := ((word bitShift: -23) bitAnd: 16rFF) - 127.
  	mantissa := word bitAnd:  16r7FFFFF.
  
  	exponent = 128 ifTrue:["Either NAN or INF"
  		mantissa = 0 ifFalse:[^ Float nan].
  		sign = 0 
  			ifTrue:[^ Float infinity]
+ 			ifFalse:[^ Float negativeInfinity]].
- 			ifFalse:[^ Float infinity negated]].
  
  	exponent = -127 ifTrue: [
  		"gradual underflow (denormalized number)
  		Remove first bit of mantissa and adjust exponent"
  		delta := mantissa highBit.
  		mantissa := (mantissa bitShift: 1) bitAnd: (1 bitShift: delta) - 1.
  		exponent := exponent + delta - 23].
  	
  	"Create new float"
  	newFloat := self new: 2.
  	newFloat basicAt: 1 put: ((sign bitOr: (1023 + exponent bitShift: 20)) bitOr: (mantissa bitShift: -3)).
  	newFloat basicAt: 2 put: ((mantissa bitAnd: 7) bitShift: 29).
  	^newFloat!

Item was changed:
  ----- Method: SqNumberParser>>readNamedFloatOrFail (in category 'parsing-private') -----
  readNamedFloatOrFail
  	"This method is used when there is no digit encountered:
  	It try and read a named Float NaN or Infinity.
  	Negative sign for -Infinity has been read before sending this method, and is indicated in the neg inst.var.
  	Fail if no named Float is found"
  		
  	neg ifFalse: [(sourceStream nextMatchAll: 'NaN')
  			ifTrue: [^ Float nan]].
  	(sourceStream nextMatchAll: 'Infinity')
  		ifTrue: [^ neg
+ 			ifTrue: [Float negativeInfinity]
- 			ifTrue: [Float infinity negated]
  			ifFalse: [Float infinity]].
  	^self expected: 'a digit between 0 and ' , (String with: (Character digitValue: base - 1))!



More information about the Packages mailing list