Don't forget us that use 1 234,56 SEK , so maybe the ideal situation is a 
(built in) function that use the national settings of the OS !
/hex





----- Ursprungligt Meddelande -----
Från: Oliver Sims <oliver.s...@simsassociates.co.uk>
Till: 'Open Object Rexx Users' <oorexx-users@lists.sourceforge.net>
Kopia:
Datum: onsdag, 08 maj 2013 20:18
Ämne: Re: [Oorexx-users] Formatting a decimal number?
DecimalFormat looks really excellent! Puts in commas and trailing zeros plus 
lots more. 

I did play around with format and several other string and parse functions, but 
in the end built a little function that did what I wanted - but it's very 
specific to my immediate needs.

What's the status of decimalFormat?  Can I expect to see it rolled into ooRexx 
at some time, or made generally available? I'd be nice to use it for the Guide.

The only thing I'd like to see added is an option to treat a number *as if* it 
had two decimal places, so formatting "123456" produces "1,234.56" or 
$1,234.56". The rationale for this is that money amounts are often stored in a 
database as some number of cents. The only time they're expressed as dollars 
and cents is when they're presented on some form of user interface 
(screen/printout/etc.). So presenting 123456 cents as $1,234.56 needs the "." 
to be inserted in the right place. 

But then, of course, all that needs is for the cents to be divided by 100 (or a 
"." inserted in the right place) before using DecimalFormat... 

--
Oliver Sims
From: Mark Miesfeld [mailto:miesf...@gmail.com] 
Sent: 08 May 2013 16:52
To: Open Object Rexx Users
Subject: Re: [Oorexx-users] Formatting a decimal number?



Hi Oliver, 

There is the format method of the String class and a similar format() built in 
function.  I've never used them much and didn't find them too easy to use.  
Once you understand them, they are probably easy.


In the incubator is an implementation of a decimal formatting class:


svn+ssh://miesf...@svn.code.sf.net/p/oorexx/code-0/incubator/decimalFormat



written by Lee.  I've never tried that at all and don't know how easy it is to 
use.


--
Mark Miesfeld






On Wed, May 8, 2013 at 10:08 AM, Oliver Sims <oliver.s...@simsassociates.co.uk> 
wrote:
I want to format decimal numbers of between 3 and 9 digits so that they have 
the following format:
x,xxx,xxx.xx
For example:
123 ==> 1.23
123456 ==> 1,234.56
123456789 ==> 1,234,567.89
etc.

I can do it with a little routine, but after some searching, I've failed to 
find an easy way to do it using one of the many ooRexx formatting functions.
Is there an easy way?

--
Oliver Sims



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users




------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Oorexx-users mailing list
Oorexx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to