[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] [subtotal] error
****** message to minivend-users from "Barry Treahy, Jr." <Treahy@mmaz.com> ******
"Dan E. Jackson III" wrote:
> ****** message to minivend-users from "Dan E. Jackson III" <danny@intermallamerica.com> ******
>
> Okay, I've been working with this for three days now and I'm stuck. My
> subtotal is mysteriously adding a penny to itself, even after I've put
> in some truncating code:
>
> [discount ALL_ITEMS] ((int ($s * .7 * 100)) / 100) [/discount]
Dan, perhaps I'm missing something but I do not believe the INT function is rounding but truncating.
Take a look:
doorstop:/# perl -e 'print (int(100.016*100)/100);print "\n"'
100.01
doorstop:/# perl -e 'print (int(100.012*100)/100);print "\n"'
100.01
doorstop:/# perl -e 'print (int(100.018*100)/100);print "\n"'
100.01
What about modifying your discount to do explicit rounding:
[discount ALL_ITEMS] ((int ($s * .7 * 100+.499)) / 100) [/discount]
doorstop:/# perl -e 'print (int(100.018*100+.499)/100);print "\n"'
100.02
doorstop:/# perl -e 'print (int(100.014*100+.499)/100);print "\n"'
100.01
Barry...
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list