Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Format BigDecimal

206 views
Skip to first unread message

David Corbin

unread,
Oct 27, 2005, 5:50:01 PM10/27/05
to
I poked around, but I could not find a clear answer on how to format a
BigDecimal. I'd like to format it so that it has exactly two decimal digits
(as in US currency).

Thanks
David


dave...@gmail.com

unread,
Oct 27, 2005, 8:05:05 PM10/27/05
to
Hi David,

You want my_big_decimal.round(2).to_s("F")

Yes, the documentation needs work.

Cheers,
Dave

mathew

unread,
Oct 28, 2005, 10:35:30 AM10/28/05
to
dave...@gmail.com wrote:
> Yes, the documentation needs work.

I've been working on it. It's not my code, I'm just one of those people
who documents stuff. I mention this here to avoid having someone else
do the same work and waste time.


mathew
--
<URL:http://www.pobox.com/~meta/>
WE HAVE TACOS

Dave Burt

unread,
Oct 28, 2005, 11:39:47 AM10/28/05
to
mathew wrote

> I've been working on it. It's not my code, I'm just one of those people
> who documents stuff. I mention this here to avoid having someone else do
> the same work and waste time.

And, on behalf of the Ruby community, a very big thank you to you and the
other documentation-writers. That means you, Gavin, James, and the others
whose names we don't know because their names are tucked away and we just
want the relevant API info.

Now, a question to you guys: how would a prospective documenter pick a
module to start on? Would one start at the Status Report?
http://www.ruby-doc.org/stdlib/status.html

Cheers,
Dave


James Edward Gray II

unread,
Oct 28, 2005, 12:34:21 PM10/28/05
to
On Oct 28, 2005, at 10:42 AM, Dave Burt wrote:

> Now, a question to you guys: how would a prospective documenter pick a
> module to start on? Would one start at the Status Report?
> http://www.ruby-doc.org/stdlib/status.html

Gavin is really the best person to answer this. He's our fearless
leader. ;)

He has a wiki about this very thing, which we are in the process of
moving to my server (so we can run it on Instiki). I believe the
data is there now, though the URL still sucks:

http://grayproductions.net:2536/rubysourcedoc/show/HomePage

I've filed a support ticket to improve the URL a little, but it
hasn't been dealt with yet.

Anyway, you question is answered in "About The Project". Hope that
helps.

James Edward Gray II

mathew

unread,
Oct 28, 2005, 4:05:22 PM10/28/05
to
Dave Burt wrote:
> Now, a question to you guys: how would a prospective documenter pick a
> module to start on? Would one start at the Status Report?
> http://www.ruby-doc.org/stdlib/status.html

I pick based on things I'm interested in and knowledgeable about, with a
preference for things I don't think anyone else is likely to document.

I started with net/http and net/ftp because I needed to use them myself;
I skipped net/imap because I don't know the protocol at all. Next I
picked fcntl, because I guessed that the number of people who had
actually used system file descriptors on Unix, were writing Ruby code,
and could also write in plain English, was probably fairly small.

BigDecimal is next because the stupidity of fixed-width binary
representations of floating point is one of my pet peeves. It made sense
when computers ran at 1MHz and had 4K of RAM, but really, isn't it time
we wrote our code to actually give the right answers?

On the other hand, I won't be touching 'Win32API'. I started on 'rss',
but decided I didn't like the code and ended up writing a replacement
instead and documenting that. (It's on RubyForge.)

Don't forget to look at the documented packages too. In some cases the
ruby-doc.org maintainers are more generous than me about what they
consider "well documented".

James Edward Gray II

unread,
Oct 28, 2005, 4:13:38 PM10/28/05
to
On Oct 28, 2005, at 3:07 PM, mathew wrote:

> Don't forget to look at the documented packages too. In some cases
> the ruby-doc.org maintainers are more generous than me about what
> they consider "well documented".

It goes the other way too. I've lobbied Gavin to mark REXML as well
documented, because I believe it's fine. We all have different
standards I guess.

James Edward Gray II


Dave Burt

unread,
Oct 28, 2005, 8:10:48 PM10/28/05
to
mathew wrote:
> BigDecimal is next because the stupidity of fixed-width binary
> representations of floating point is one of my pet peeves. It made sense
> when computers ran at 1MHz and had 4K of RAM, but really, isn't it time we
> wrote our code to actually give the right answers?

Ah, you want Rational. Especially after my patch (RCR 320 or so) has been
included.

And mathn. 1/2 #=> 1/2 like it should.

I'm not sure what BigDecimal is for ... maybe money or crazy stuff like
that.

Cheers,
Dave


David Corbin

unread,
Oct 30, 2005, 9:55:44 AM10/30/05
to
On Thursday 27 October 2005 08:07 pm, dave...@gmail.com wrote:
> Hi David,
>
> You want my_big_decimal.round(2).to_s("F")
>

Many thanks.


0 new messages