<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3199" name=GENERATOR></HEAD>
<BODY
style="WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-break: after-white-space">
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>Ok, don't beat me.. I'm not proud of this but I have to
use until I manage to have something better.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>String>>asScaledDecimal:
aQuantityOfDigits<BR> "Answers the scaled decimal with aQuantityOfDigits
<BR> of precision represented by the receiver."<BR> <BR> ^
[:number|<BR> number isZero<BR> ifTrue:[0 asFloat
asScaledDecimal: aQuantityOfDigits]<BR> ifFalse:[number
asScaledDecimal: aQuantityOfDigits]] value: self asNumber
</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>so my converter can do this depending on it's own
configuration (not only used for money):</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>MVPNumberToText>>rightToLeft:
aString<BR> "Answers the result of converting aString to a Number or
aScaledDecimal."</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007> ^self
hasInputDigits<BR> ifTrue:[aString asScaledDecimal:
inputDigits]<BR> ifFalse:[aString asNumber]</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>Adding the horrible hack:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>ScaledDecimal>>printOn: aStream
<BR> "Reimplementation - Object 'printing' method."<BR> | aFraction
tmpFractionPart |<BR> self < 0 ifTrue: [aStream nextPut:
$-].<BR> aFraction := fraction abs.<BR> aStream nextPutAll: aFraction
rounded printString.<BR> scale = 0 ifTrue: [^ aStream nextPutAll:
's0'].<BR> aStream nextPut: $..<BR> tmpFractionPart := aFraction
fractionPart.<BR> 1 to: scale<BR> do:
<BR> [:dummy | <BR> tmpFractionPart :=
tmpFractionPart * 10.<BR> (10 <= tmpFractionPart
rounded)<BR> ifTrue:[aStream nextPut:
$0]<BR> ifFalse:[aStream nextPut: (Character digitValue:
tmpFractionPart rounded)].<BR> tmpFractionPart :=
tmpFractionPart fractionPart].</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007>I was able to make the values to
behave,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=046212819-22112007> thanks,</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" color=#0000ff size=2></FONT> </DIV>
<DIV align=left><SPAN class=250542422-20122006>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt" align=left><?xml:namespace prefix
= st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:PersonName
ProductID="Sebastian Sastre " w:st="on"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'">Sebastian
Sastre<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
/><o:p></o:p></SPAN></st1:PersonName></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Trebuchet MS'"><o:p> </o:p></SPAN></SPAN><BR></P></DIV>
<BLOCKQUOTE
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=es dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>De:</B>
squeak-dev-bounces@lists.squeakfoundation.org
[mailto:squeak-dev-bounces@lists.squeakfoundation.org] <B>En nombre de </B>tim
Rowledge<BR><B>Enviado el:</B> Jueves, 22 de Noviembre de 2007
17:10<BR><B>Para:</B> The general-purpose Squeak developers
list<BR><B>Asunto:</B> Re: 5.3 printShowingDecimalPlaces: 2 displays '5.29'
insteadof'5.30'<BR></FONT><BR></DIV>
<DIV></DIV><BR>
<DIV>
<DIV>On 22-Nov-07, at 11:00 AM, Sebastian Sastre wrote:</DIV><BR
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
<DIV
style="WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-break: after-white-space">
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007>Thanks Tim,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> </SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> may be I should clarify that
it's only for presentation. The mone value is stored as anMeasure of it's
monetary unit in the Aconcagua framework.</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> But I'm curious about your
answer. Let's supose the user enters in some input widget with keyboard
the '5.30' value. That will end as a Float at some point. Do you
suggest I convert that to a ScaledDecimal? (to store/comare,
etc)?</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> I'm evaluating
this:</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> (5.3 asScaledDecimal: 2)
<BR></SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face="Trebuchet MS" color=#0000ff size=2><SPAN
class=984495318-22112007> and also obtainig: '
5.29s2'</SPAN></FONT></DIV></DIV></BLOCKQUOTE><BR></DIV>
<DIV>That must surely count as a bug and I'd hazard a guess that it happens
because some code is comparing floats; I've not looked at the code but I've
seen it too many times not to suspect it.</DIV>
<DIV><BR class=webkit-block-placeholder></DIV>
<DIV>As for your input widget, I'd try to make it give you the string and
directly convert that to a 2dp scaled decimal rather than letting it give you
a float. If there isn't a String>asScaledFloat: type method then I guess
you get to write it :-)</DIV><BR>
<DIV apple-content-edited="true"><SPAN class=Apple-style-span
style="WORD-SPACING: 0px; FONT: 14px Palatino; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; border-spacing: 0px 0px; khtml-text-decorations-in-effect: none; apple-text-size-adjust: auto; orphans: 2; widows: 2">
<DIV
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space">
<DIV><BR class=khtml-block-placeholder></DIV>
<DIV>tim</DIV>
<DIV>--</DIV>
<DIV>tim Rowledge; tim@rowledge.org; <A
href="http://www.rowledge.org/tim">http://www.rowledge.org/tim</A></DIV>
<DIV>All the simple programs have been written, and all the good names
taken.</DIV></DIV><BR
class=Apple-interchange-newline></SPAN></DIV><BR></BLOCKQUOTE></BODY></HTML>