I am looking for something like printf's for streams. I need to
control the precision of numbers being output to a text file. Thanks, David _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
You may want to take a look at the method below. IIRC, it has been
added for 7.7, but should work on 7.6 and earlier. Number>>printFormat: aFormatPattern "Shorthand for printing numbers with a given format. See NumberPrintPolicy's comment for format description." "100 printFormat: '#.0'" "Double pi printFormat: '000.####'" | stream | stream := (String new: aFormatPattern size) writeStream. self printOn: stream format: aFormatPattern. ^stream contents -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of David Finlayson Sent: Wednesday, May 13, 2009 2:32 PM To: VW NC Subject: [vwnc] Something like printf? I am looking for something like printf's for streams. I need to control the precision of numbers being output to a text file. 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 |
In reply to this post by David Finlayson-4
On Wed, May 13, 2009 at 2:31 PM, David Finlayson <[hidden email]> wrote: I am looking for something like printf's for streams. I need to You could start from Squeak's facilities such as printPaddedWith:to:, e.g. "Answer the string containing the ASCII representation of the receiver padded on the left with aCharacter to be at least on aNumber
integerPart characters and padded the right with aCharacter to be at least anInteger fractionPart characters."
((1000 / 3) roundTo: 0.001) printPaddedWith: $_ to: 4.2 '_333.333_' Buggy but fixable.
Thanks, _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by David Finlayson-4
The StandardLibInterface interface lets you do things like '[%*.*f][%*.*e]' sprintfWithArguments: #(12 2 3.141592653 12 2 3.141592653) ==> '[ 3.14][ 3.14e+00]' HTH, Joachim Geidel Am 13.05.09 23:31 schrieb David Finlayson: I am looking for something like printf's for streams. I need to _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by David Finlayson-4
ObjectStudio has full support of printf
Georg Georg Heeg eK, Dortmund und Köthen, HR Dortmund A 12812 Tel. +49-3496-214328, Fax +49-3496-214712 > -----Ursprüngliche Nachricht----- > Von: [hidden email] [mailto:[hidden email]] Im Auftrag > von David Finlayson > Gesendet: Mittwoch, 13. Mai 2009 23:32 > An: VW NC > Betreff: [vwnc] Something like printf? > > I am looking for something like printf's for streams. I need to > control the precision of numbers being output to a text file. > > 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 |
Free forum by Nabble | Edit this page |