Format BigDecimal

D

David Corbin

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
 
D

dave.burt

Hi David,

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

Yes, the documentation needs work.

Cheers,
Dave
 
D

Dave Burt

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
 
J

James Edward Gray II

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
 
J

James Edward Gray II

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
 
D

Dave Burt

mathew said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top