# No to\_d in BigDecimal

**URL:** <https://www.ruby-forum.com/t/no-to-d-in-bigdecimal/54946>\
**Category:** Ruby\
**Created:** [March 15, 2006, 1:04pm UTC](https://www.ruby-forum.com/t/no-to-d-in-bigdecimal/54946 "2006-03-15T13:04:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [March 15, 2006, 1:04pm UTC](https://www.ruby-forum.com/t/no-to-d-in-bigdecimal/54946/1 "2006-03-15T13:04:05Z")

</div>

Hi everyone

I’m new to the Ruby bandwagon. To get warmed up I’ve took on the gentle  
task  
of modifiying the PostgreSQL Rails adapter to read and write decimals as  
BigDecimals. Oops bad choice 🙂 I’m still working on that though, so I  
won’t post the half-baked patch yet.

## Anyway the immediate issue I have is actually simple. Late last night I managed to get it reading BigDecimals, but my test case was trying to call to\_d on the objects I was getting back. Can’t remember why (it was late

brain was fried), but I had to open the class and add it in (return  
self).

This seems like a strange omission from the BigDecimal class. Anyone  
know if  
there’s a reason for that? If not could it be added in? I’m scared to  
touch  
it because it’s a C library.

Ashley

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [March 17, 2006, 8:20pm UTC](https://www.ruby-forum.com/t/no-to-d-in-bigdecimal/54946/2 "2006-03-17T20:20:51Z")

</div>

On Wednesday 15 March 2006 06:02, Ashley M. wrote:

> brain was fried), but I had to open the class and add it in (return self).
> 
> This seems like a strange omission from the BigDecimal class. Anyone know  
> if there’s a reason for that? If not could it be added in? I’m scared to  
> touch it because it’s a C library.

If you’re looking for double, then you’re probably looking for to\_f  
(float).

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [March 17, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/no-to-d-in-bigdecimal/54946/3 "2006-03-17T23:49:24Z")

</div>

Ashley M. wrote:

> This seems like a strange omission from the BigDecimal class. Anyone know  
> if  
> there’s a reason for that? If not could it be added in? I’m scared to  
> touch  
> it because it’s a C library.

Looks to me like it’s missing.  
How about we add this near line 1310 of ext/bigdecimal/bigdecimal.c?

- rb\_define\_method(rb\_cBigDecimal, “to\_d”, BigDecimal\_uplus, 0);

Cheers,  
Dave
