[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bug in the money gem?

Eric LIn

9/25/2008 6:32:00 PM

For anyone of you using the money gem (http://dist.leetsof...
money/), I noticed today that 0 - 100 does not equal -100, it equals
100 instead (all numbers here represent Money objects). Do any of you
find that odd?

Eric
11 Answers

P.K.

1/11/2008 2:58:00 AM

0

Exactly, in the Iowa bullshit caucuses everybody knows how you vote so you
can't say that you would vote for a Black man then vote differently. In N.H. it
was a secret ballot so you can be politically correct and say that you like the
Black dude but vote against him. I call it the Schwoogie Factor. Considering
that it's stupid White people that are going gaga over Obama, I don't think he
will do well in S.C. The Black people just don't like him because he is an
"Oreo".

Art Clemons wrote:

> theloneranger100@aol.com wrote:
>
> > Yup........This is gonna be FUNNY........Think the Lefties might learn
> > that "Polls" are UNRELIABLE?.
>
> There's a more likely explanation, you can call it the African-American
> candidate factor. Look up the polls for Tom Bradley when he ran for
> Governor of California, Harvey Gantt in a Senate race in NC, or Doug Wilder
> during his run for Governor of VA. It would appear that race trumps
> honesty during such polls.
>
> You would have folks believe that polling is generally unreliable, that
> doesn't appear to be true.

Art Clemons

1/11/2008 6:41:00 AM

0

theloneranger100@aol.com wrote:

> Really?.........Then there must be a Thousand Polls taken Every DAY,
> DumbAss.........Because the Media Trumpets most of them...........

There aren't thousands of large polling organizations in the US. Even
independent pollsters are limited in number and most have had some
association in the past with the larger polling organizations. You love to
make claims like that though don't you. You missed the point. I pointedly
note that you likely haven't read polls from more than 20 pollsters.

Art Clemons

1/11/2008 6:42:00 AM

0

P.K. wrote:

> Considering
> that it's stupid White people that are going gaga over Obama, I don't
> think he will do well in S.C. The Black people just don't like him because
> he is an "Oreo".

I'm not sure the Oreo claim really fits Obama. He just isn't focused on
race, but does admit that it exists unlike the typical republican shill.

queenie

1/13/2008 2:42:00 AM

0

On Thu, 10 Jan 2008 15:06:11 -0500, Art Clemons
<ArtClemons@aolSPAM.com> wrote:

>You would have folks believe that polling is generally unreliable, that
>doesn't appear to be true.

I wonder how the question was phrased? Was the question "Are you
going to vote for Obama?" or "Would you support an African-American?"

queenie

1/13/2008 2:49:00 AM

0

On Thu, 10 Jan 2008 18:57:46 -0800, "P.K." <george@vcnet.com> wrote:

>The Black people just don't like him because he is an
>"Oreo".

And maybe some Black people don't support him because they feel he
isn't the best qualified to be POTUS. The one we have now wasn't the
best qualified and look at the mess he made.

Art Clemons

1/13/2008 5:59:00 AM

0

queenie wrote:

> I wonder how the question was phrased? ?Was the question "Are you
> going to vote for Obama?" ?or "Would you support an African-American?"

Some of the major polling orgs publish the exact questions asked. You can
try going to the websites of the major ones and seeing what the questions
were. I suspect though that nobody asked if voters would not vote for
Obama because he is an African-American.

queenie

1/13/2008 5:22:00 PM

0

On Sun, 13 Jan 2008 00:59:07 -0500, Art Clemons
<ArtClemons@aolSPAM.com> wrote:

>queenie wrote:
>
>> I wonder how the question was phrased? ?Was the question "Are you
>> going to vote for Obama?" ?or "Would you support an African-American?"
>
>Some of the major polling orgs publish the exact questions asked. You can
>try going to the websites of the major ones and seeing what the questions
>were. I suspect though that nobody asked if voters would not vote for
>Obama because he is an African-American.

Right. And the question "Are you going to *vote* for Obama?" was
probably not asked either. I think the question was "Would you
support Obama?" and the media twisted the "yes" responses to mean
people said they would "vote" for Obama. Hence, the big surprise.

Art Clemons

1/13/2008 8:23:00 PM

0

theloneranger100@aol.com wrote:

>> There aren't thousands of large polling organizations in the US.
>
> Really, DumbAss?.........

Are there thousands of large polling entities in the US? Really, why don't
you demonstrate that somehow?

> You love to
>> make claims like that though don't you.
>
> Like what a DUMBASS you are?..

Actually that is a good example. You make claims then cannot back them.
You then go on your dumbass role so that you can pretend you won. Shame
you haven't yet figured out how to even begin to outthink those with whom
you disagree.

Mark Thomas

9/25/2008 6:45:00 PM

0

On Sep 25, 2:32 pm, Eric LIn <ericlin...@gmail.com> wrote:
> For anyone of you using the money gem (http://dist.leetsof...
> money/), I noticed today that 0 - 100 does not equal -100, it equals
> 100 instead (all numbers here represent Money objects).  Do any of you
> find that odd?

Yes, it's odd. The problem is line 80:

# File lib/money/money.rb, line 79
79: def -(other_money)
80: return other_money.dup if cents.zero?
81: return dup if other_money.cents.zero?
82:
83: if self.cents == 0 or currency == other_money.currency
84: Money.new(cents - other_money.cents, other_money.currency)
85: else
86: Money.new(cents - other_money.exchange_to(currency).cents,
currency)
87: end
88: end

Try commenting line 80 out. I don't see any reason why the class
wouldn't handle negative values, though I didn't look carefully.

-- Mark.

Michael Guterl

9/25/2008 7:05:00 PM

0

On Thu, Sep 25, 2008 at 2:34 PM, Eric LIn <ericlin852@gmail.com> wrote:
> For anyone of you using the money gem (http://dist.leetsof...
> money/), I noticed today that 0 - 100 does not equal -100, it equals
> 100 instead (all numbers here represent Money objects). Do any of you
> find that odd?
>
I'm not sure, but it seems a bit strange. Here is the offending code:

# File lib/money/money.rb, line 79
79: def -(other_money)
80: return other_money.dup if cents.zero?
81: return dup if other_money.cents.zero?
82:
83: if self.cents == 0 or currency == other_money.currency
84: Money.new(cents - other_money.cents, other_money.currency)
85: else
86: Money.new(cents - other_money.exchange_to(currency).cents, currency)
87: end
88: end

I think the first return would make sense if the other_money variable
had a negative value associated with it, however, other_money's value
is not negative.

HTH,
Michael Guterl