[vwnc] Suffix when printing numbers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Suffix when printing numbers

David Lattimore
When printing FixedPoint, Double etc, an #exponentCharacter is added at
the end.  This is probably a good thing when debugging, since it lets
you see what kind of number you've got, but when printing for end-user
purposes this isn't what we want.  Is there a protocol that we've missed
that lets us print numbers without this suffix?

Thanks,
David

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Suffix when printing numbers

Boris Popov, DeepCove Labs (SNN)
David,

NumberPrintPolicy
 print: 12345.678s3
 using: '#,##0.000'

We've also added a number of simple extensions to the codebase here to
allow you to shortcut that with,

12345.678s3 printUsing: '#,##0.000'

See attached,

Hope this helps!

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
Behalf
> Of David Price
> Sent: Sunday, April 13, 2008 10:54 PM
> To: vwnc-list
> Subject: [vwnc] Suffix when printing numbers
>
> When printing FixedPoint, Double etc, an #exponentCharacter is added
at
> the end.  This is probably a good thing when debugging, since it lets
> you see what kind of number you've got, but when printing for end-user
> purposes this isn't what we want.  Is there a protocol that we've
missed
> that lets us print numbers without this suffix?
>
> Thanks,
> David
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

Others-printPolicyClass.st (1K) Download Attachment
Object-printUsing.st (546 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Suffix when printing numbers

Travis Griggs-3
In reply to this post by David Lattimore

On Apr 13, 2008, at 10:53 PM, David Price wrote:

> When printing FixedPoint, Double etc, an #exponentCharacter is added  
> at
> the end.  This is probably a good thing when debugging, since it lets
> you see what kind of number you've got, but when printing for end-user
> purposes this isn't what we want.  Is there a protocol that we've  
> missed
> that lets us print numbers without this suffix?


Some sites add displayString extensions to these classes. Not overly  
elegant or anything.

--
Travis Griggs
Objologist
"Is success the potential of what could be, or the reality of what is?"


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Suffix when printing numbers

David Lattimore
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Thanks for the replies Boris and Travis.

Because we mostly wanted to get the same behaviour as GemStone (which
doesn't add these suffixes), we ended up just implementing asString on
Number as follows:

asString
    ^super asString reject: [:char | char = self class exponentCharacter]

Not the nicest thing to have to do, but oh well.

David and Steve

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Suffix when printing numbers

Nicolas Cellier-3
David Price wrote:

> Thanks for the replies Boris and Travis.
>
> Because we mostly wanted to get the same behaviour as GemStone (which
> doesn't add these suffixes), we ended up just implementing asString on
> Number as follows:
>
> asString
>     ^super asString reject: [:char | char = self class exponentCharacter]
>
> Not the nicest thing to have to do, but oh well.
>
> David and Steve

1.0e30 -> 1.030
:(

I hope you handle only small numbers.

Nicolas

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc