[Pharo-project] SIXX problem for ScaledDecimal

Dario Trussardi dario.trussardi at tiscali.it
Thu May 19 10:42:02 CEST 2011


Hi,

	i found some problem into Gemstone relative to   SIXX support for manage ScaledDecimal instances.


	I do some test into Pharo and i found error when i read the sixx declaration relative to ScaledDecimal :

		<sixx.object sixx.id="0" sixx.type="ScaledDecimal" >123.456s3</sixx.object>


	For solve this error i define the ScaledDecimal :

		readSixxContentStringFrom: aStream

				
			| numerator scale |
	
			numerator := aStream upTo: $s .
	
			scale := aStream upToEnd. 
	
	
			^ self newFromNumber:  numerator asNumber scale: scale asNumber 


Now my doubt is relative to string size and performance.

A)	If i write 

		<sixx.object sixx.id="0" sixx.type="ScaledDecimal" >123.456s3</sixx.object>


	i have small string in sixx declartion but when create a ScaledDecimal from sixx the system execute the:

		newFromNumber: aNumber scale: anInteger
			| aFraction |
			aFraction := aNumber asFraction.   
			^aFraction isFraction
			ifTrue: [self new setNumerator: aFraction numerator denominator: aFraction denominator scale: anInteger]
			ifFalse: [self new setNumerator: aFraction denominator: 1 scale: anInteger]


	What is the performance relative to : 			aFraction := aFloat asFraction.    ????


	

B) 	The alternative is to write a sixx declaration with:

		<sixx.object sixx.id="0" sixx.type="ScaledDecimal" >(8687443681197687/70368744177664s3)</sixx.object>


	in this case the sixx string is big but the ScaledDecimal instance creation is direct:


		readSixxContentStringFromA: aStream

			" with numerator and denominator "
		| numerator denominator scale |
		aStream next. "skip $("
		numerator := aStream upTo: $/ .
		denominator := aStream upTo: $s.
		scale := aStream upTo: $).
	
		^ self new setNumerator:  numerator asNumber denominator: denominator asNumber scale:  scale asNumber



Any pointers would be greatly appreciated !

	Thanks,

		Dario





More information about the Pharo-project mailing list