in reply to >= returning unexpected result

Some more code, as requested:

Retrieving the values (@grid is an array of array references retrieved from a mysql database with DBI). They are returned by reference and stuck in %dbdata:

my %data = ( balance => $grid[0][0], overdraft => $grid[0][1], status => uc($grid[0][2]), );

The following is part of a subroutine that is passed a bunch of parameters and then:

my %data = @_; my $amount = $data{amount} ? $data{amount} : undef;

Then the test:

unless( $dbdata{balance}+$dbdata{overdraft} >= $amount ){ MyModule::Logger::log(BANK_ACCOUNT => "Debit FAILED user($self-> +{USER_ID}) reason($reason) amount($amount) because this failed: balan +ce($dbdata{balance})+overdraft($dbdata{overdraft})>=amount($amount)") +; return 0; }

Example output:

Debit FAILED user(<removed>) reason(ORDER_PAYMENT) amount(1742) becaus +e this failed: balance(1742)+overdraft(0)>=amount(1742)

Replies are listed 'Best First'.
Re^2: >= returning unexpected result
by tlm (Prior) on Apr 12, 2005 at 11:12 UTC

    I find it surprising that money amounts would be stored as ints in the MySQL database.

    the lowliest monk