Re: [PHP] Math Weirdness - Can it be done with integers alone??
There's an algorithm known as banker's rounding that I thought all US banks used. I'm on blackberry right now so I don't have a pointer, but essentially you round to the nearest even cent. 1.5 goes to 2, as does 2.5. Waynn On 7/15/08, tedd [EMAIL PROTECTED] wrote: At 4:15 PM -0400 7/14/08, Robert Cummings wrote: Nope, banks can't round like that when calculating your daily interest :) Cheers, Rob. I do know that when it comes to interest you pay them, they round up. When it comes to interest they pay you, they round down -- and why not? A decision has to be made -- you can't pay someone less than a penny. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Weirdness - Can it be done with integers alone??
tedd schreef: At 4:45 PM -0400 7/14/08, Daniel Brown wrote: That's as far OT as I'm going, but it's worth noting how regulation doesn't do shit if it's not enforced. The only thing that's regulated AND enforced is what you owe the government. actually your under no obligation to declare any income tax in your country, look into it Don't get me started. :-) Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
[quote] I don't quite understand your problem, but I use integers for any monetary workings as you can guarantee it is accurate (obviously, you work in pence or cents rather than GBP or USD). Alex Hello Alex, I was reading through this thread, and I was curious about what methods you use to handle fractions of a dollar and/or fractions of a penny if you are always using integers. Do you only use a decimal for printing? do you adjust all interest rates, etc...then as well? How about when interest calculations result in fractions of pennies, how do you handle it then? Basically, I can't see how it could be done with just integers alone? thanks dank [/quote] To be honest, I haven't used it for any complicated use - shopping carts are additive contraptions. However, I don't see the problem. 1) I use Smarty a lot - I use a plugin to format the integer to a price (ie divide by 100 and display in 2 decimal places). So yes, I only put the decimal place there to print. 2) Why do interest rates need to be changed?? Take £123.45 @ 5%. 123.45 * 1.05 = (12345 [pennies] / 100) [pounds] * 1.05 = (12345 * 1.05) / 100 Same calculation in my mind!! (Tell me if I have missed the point!!) 3) If you have a fraction of a penny - round it!! Surely, that's what the banks do!! It's a penny!! I think it can be done with integers alone - let me know if you disagree!! Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008 17:58 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
On Mon, 2008-07-14 at 21:09 +0100, Alex Chamberlain wrote: [quote] I don't quite understand your problem, but I use integers for any monetary workings as you can guarantee it is accurate (obviously, you work in pence or cents rather than GBP or USD). Alex Hello Alex, I was reading through this thread, and I was curious about what methods you use to handle fractions of a dollar and/or fractions of a penny if you are always using integers. Do you only use a decimal for printing? do you adjust all interest rates, etc...then as well? How about when interest calculations result in fractions of pennies, how do you handle it then? Basically, I can't see how it could be done with just integers alone? thanks dank [/quote] To be honest, I haven't used it for any complicated use - shopping carts are additive contraptions. However, I don't see the problem. 1) I use Smarty a lot - I use a plugin to format the integer to a price (ie divide by 100 and display in 2 decimal places). So yes, I only put the decimal place there to print. 2) Why do interest rates need to be changed?? Take £123.45 @ 5%. 123.45 * 1.05 = (12345 [pennies] / 100) [pounds] * 1.05 = (12345 * 1.05) / 100 Same calculation in my mind!! (Tell me if I have missed the point!!) 3) If you have a fraction of a penny - round it!! Surely, that's what the banks do!! It's a penny!! Nope, banks can't round like that when calculating your daily interest :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Weirdness - Can it be done with integers alone??
On Mon, Jul 14, 2008 at 4:15 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, banks can't round like that when calculating your daily interest :) If it works in their favor, you'd be surprised what they do. That's why extending TILA to banks in the US is such a big deal to me, yet gets no attention. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Weirdness - Can it be done with integers alone??
On Mon, 2008-07-14 at 16:25 -0400, Daniel Brown wrote: On Mon, Jul 14, 2008 at 4:15 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, banks can't round like that when calculating your daily interest :) If it works in their favor, you'd be surprised what they do. That's why extending TILA to banks in the US is such a big deal to me, yet gets no attention. I'm not completely sure about the U.S. but banks in Canada are regulated... fortunately :) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
On Mon, 2008-07-14 at 16:25 -0400, Daniel Brown wrote: On Mon, Jul 14, 2008 at 4:15 PM, Robert Cummings [EMAIL PROTECTED] wrote: Nope, banks can't round like that when calculating your daily interest :) If it works in their favor, you'd be surprised what they do. That's why extending TILA to banks in the US is such a big deal to me, yet gets no attention. I'm not completely sure about the U.S. but banks in Canada are regulated... fortunately :) Cheers, Rob. Ok, I may have been wrong about the banks thing - don't quote me on it!! However, there must be some degree of accuracy?? Which can then be reflected in your integers. Alex No virus found in this outgoing message. Scanned by AVG Free 8.0 Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database: 270.4.10/1550 - Release Date: 13/07/2008 17:58 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Weirdness - Can it be done with integers alone??
On Mon, Jul 14, 2008 at 4:28 PM, Robert Cummings [EMAIL PROTECTED] wrote: I'm not completely sure about the U.S. but banks in Canada are regulated... fortunately :) They are here, too, to a certain extent. The problem is, they can create their own rules that cost the customer a fortune, and still somehow complain that they need to have rates cut, raised, or otherwise modified so that they can make more of a profit. I have to empathize with them, though. I don't know how I'd survive if I was someone like former Wachovia CEO Ken Thompson, who only got a $7 Million bonus in 2004 (in addition to $11.1 Million in salary, stock, et cetera). And speaking of Wachovia, using them by example, the audacity isn't even masked: Shares of Wachovia dropped as much as 11 percent to their lowest level since 1991 after the bank said it might lose as much as $2.8 billion in the second quarter. It declined to offer specifics on how it plans to reduce balance sheet risk or whether it needs more capital or might again cut the dividend. Wachovia said it approached [Robert] Steel for the [position of CEO], offering him a package that could total $38.1 million in salary, bonus and other awards in his first year. I'm no genius (despite what MENSA may say ;-P), but if I was so horribly worried about how to begin cutting expenses, the first thing I'd do is STOP RAISING @$#%ING SALARIES. If I even got a cost of living increase, I'd be happy but if I got an exorbitant cost of living increase in the millions, you wouldn't hear me complain. And I'm sure many of you remember when Exxon Mobil CEO Lee Raymond retired in December of 2006. Despite rising gas and oil prices, he was compensated more than $686 million from 1993 to 2005, according to an analysis done for the New York Times by Brian Foley, an independent compensation consultant. That is $144,573 for each day he spent leading Exxon's God pod, as the executive suite at the company's headquarters in Irving, Texas, is known. Despite the company's performance, some shareholders, academics, corporate governance experts and consumer groups were taken aback when they learned for the first time this week the details of Raymond's total compensation package, including the more than $400 million he received in his final year at the company. That's as far OT as I'm going, but it's worth noting how regulation doesn't do shit if it's not enforced. -- /Daniel P. Brown Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Math Weirdness - Can it be done with integers alone??
At 4:15 PM -0400 7/14/08, Robert Cummings wrote: Nope, banks can't round like that when calculating your daily interest :) Cheers, Rob. I do know that when it comes to interest you pay them, they round up. When it comes to interest they pay you, they round down -- and why not? A decision has to be made -- you can't pay someone less than a penny. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Math Weirdness - Can it be done with integers alone??
At 4:45 PM -0400 7/14/08, Daniel Brown wrote: That's as far OT as I'm going, but it's worth noting how regulation doesn't do shit if it's not enforced. The only thing that's regulated AND enforced is what you owe the government. Don't get me started. :-) Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php