Format BigDecimal

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

Hi David,

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

Yes, the documentation needs work.

Cheers,
Dave

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

···

dave.burt@gmail.com wrote:

Yes, the documentation needs work.

--
<URL:http://www.pobox.com/~meta/&gt;
          WE HAVE TACOS

Many thanks.

···

On Thursday 27 October 2005 08:07 pm, dave.burt@gmail.com wrote:

Hi David,

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

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

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

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

···

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

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".

mathew

···

--
<URL:http://www.pobox.com/~meta/&gt;
          WE HAVE TACOS

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

···

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".

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