View Full Version: Simple fix to a simple problem

Trukz Forums > Suggestion Box > Simple fix to a simple problem


Title: Simple fix to a simple problem


audigex - December 6, 2008 04:29 PM (GMT)
I'm sure everyone's seen it: you try to deposit/withdraw at the bank and get that "Not enough money in your bank/you do not have this much money" etc message. No, it's not a big deal, but it's a bug nontheless.

Now, I know the reason why: It's because asp's round function rounds numbers up... so if the database says I have
$1.214 it rounds it to 1.21, i try to deposit 1.21 and it's less than what I have, all's fine

but if I have
$1.215 it rounds it to 1.22. I try to deposit 1.22 and 1.22>1.214; the check decides that I don't have enough to deposit and won't let me.

Admins, could the displaying of money rely not on the round() function, but instead on a substr? By chopping off anything after the first two decimal places, I see the rounded down figure; the amount I can actually deposit, rather than the closes number to 2 dp, which throws the verification off and gives an error.

Edit: how about: (Psuedo coded, but none of this should be hard to swap into ASP)
CODE

function Floor(double cash)
{
       newCash = newCash*100
'Round() rounds up/down as normal
newCash = Round(newCash)

'test rounded value against the non rounded value
'if greater, subtract 1
if newCash > cash
       {
        newCash--
       }
       newCash = newCash/100
       return newCash
}


Then just run this when printing out any monetary values.

Sweetchuck - December 6, 2008 04:47 PM (GMT)
And then we could take all those fractions of a cent and funnel them into another account, and suddenly have over $400,000 :)

Actually, it sound like a good idea if the fix is that easy. I've been annoyed by this for a while.

Elephant - December 6, 2008 06:45 PM (GMT)
Ill agree that this is a simple problem with a simple fix that annoys me to, but my fix is even easier. . .always keep $.01 on hand with your driver. Not very hard to do.

audigex - December 6, 2008 09:17 PM (GMT)
Elephant, the point isn't that the user can get around it, the point is that the bug shouldn't be there.

Please note that my solution would leave the fractions of a cent on your account... your "appeared" balance would be 0.00, but your actual amount may be 0.00621 etc. so as soon as you get another 0.00379 you'll get an extra penny. All it is is that you can only (but always) deposit the number of whole pennies you have... any extra bits of penny stay in your hand. Nobody loses any money.

Elephant - December 7, 2008 03:52 AM (GMT)
QUOTE (audigex @ Dec 6 2008, 09:17 PM)
Elephant, the point isn't that the user can get around it, the point is that the bug shouldn't be there.

Please note that my solution would leave the fractions of a cent on your account... your "appeared" balance would be 0.00, but your actual amount may be 0.00621 etc. so as soon as you get another 0.00379 you'll get an extra penny. All it is is that you can only (but always) deposit the number of whole pennies you have... any extra bits of penny stay in your hand. Nobody loses any money.

I'm not arguing that the bug shouldn't be there, but again my solution is easier. Also no one will be losing money and it could allow the developers or whoever would fix this to focus on additions, which I would rather see happen then this minor inconvenience be fixed.

KillerKoel - December 7, 2008 07:50 AM (GMT)
I've noticed this and it would be cool if it could be fixed

csmdad - December 9, 2008 02:00 PM (GMT)
So we're taking pennies from the crippled kids' jar? :blink:

Didn't they do this in Superman 3?

I'm really contributing nothing to this... sorry for wasting your reading time.

I like the code change. Good thinkin' guys.




Hosted for free by InvisionFree