Bug in tip calculator

Bug in tip calculator

New postby Anguish on Thu Feb 04, 2010 5:21 pm

This has no real-life impact but it's still worth noting.

If you enter $10,000,000 as the Bill Total, the TC properly calculates both the Tip and Total. (Say 10%, it's $1,000,000 and $11,000,000 respectively.)

Add a zero.

Bill Total is $100,000,000. Tip is calculated correctly (10% at $10,000,000). Total is incorrect at $21,474,836.47 (again at 10%).

It gets better. Add a zero.

Bill total is $1,000,000,000. Tip is now incorrect as well as Total. (10% at $21,474,836.47 for both.)

Add a zero.

Bill total is $10,000,000,000. Tip and total remain unchanged since last values.

Add a zero.

Bill total is $100,000,000,000. Tip and total remain unchanged since last values.

Add a zero.

It finally tells you the field is full.

I very much suspect this is entirely to do with register length for the variables used. The obvious fix is to limit the tip calculator to a more-than-reasonable value, like one million. That might have some impact on users using currency that's more finely divided than dollars, but I suspect not.
Anguish
 
Posts: 8
Joined: Thu Feb 04, 2010 12:43 pm

Re: Bug in tip calculator

New postby marwatk on Thu Feb 04, 2010 7:36 pm

Good find, that's some serious testing you're doing :)

This would become problematic if the hyperinflation guys are right, heh.

-Marcus
Versatile Monkey
For more/quicker help make sure to check out the user manuals
marwatk
Lead (and only) Monkey
 
Posts: 2596
Joined: Sun Nov 02, 2008 9:20 pm


Return to Bugs and help

Who is online

Users browsing this forum: No registered users and 3 guests

cron