Re: [PHP] Calculations
tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
Jochem Maas wrote: tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) Pffft, kids. Rocks weren't even invented in my day. We had to use dirt. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
Best proving I'm old line ever had to have been I *named* dirt!.. forget where I saw that. Had to share :) -TG Top posting is for people who remember the conversation and don't care to see it again :) = = = Original message = = = Jochem Maas wrote: tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) Pffft, kids. Rocks weren't even invented in my day. We had to use dirt. -- John C. Nichel IV ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
At 2:36 PM +0200 7/6/06, Jochem Maas wrote: tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) That was an old thread -- are you finally getting to it? You're falling behind in your reading. :-) tedd PS: ^ was used for other things other than a bitwise xor operator as portions of this thread has shown. I just don't remember them -- of course, I don't remember what I had for breakfast yesterday either. -- 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] Calculations
At 8:45 AM -0400 7/6/06, John Nichel wrote: Jochem Maas wrote: tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) Pffft, kids. Rocks weren't even invented in my day. We had to use dirt. One more plagiarized joke like that and you're going into my kill file. ;-) 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] Calculations
On Thu, 2006-07-06 at 08:45, John Nichel wrote: Jochem Maas wrote: tedd wrote: At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) Pffft, kids. Rocks weren't even invented in my day. We had to use dirt. Rock predates dirt. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
At 12:32 PM -0400 7/6/06, Robert Cummings wrote: On Thu, 2006-07-06 at 08:45, John Nichel wrote: Jochem Maas wrote: I guess the chinese-straw-hat operator has had it's meaning changed by general consensus since the days when you were programming with rocks ;-) Pffft, kids. Rocks weren't even invented in my day. We had to use dirt. Rock predates dirt. Cheers, Rob. Rob: You're absolutely right -- I should have caught that. I'm so used to him being right all the time, that it didn't enter my mind that he wasn't. Yeah, John -- dirt comes from rocks -- so there. :-p :-) -- note happy face -- no need to threaten me with your kill file. :-) 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] Calculations
On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations and exponents in languages
Huh.. thanks for the illustration Robin. Can't say that I did much with exponents when I've played around with perl or python or C.. and never worked with Java. You've expanded my view. Ok, now what languages DO use ^ for exponents? -TG = = = Original message = = = On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
At 11:27 AM +0300 6/28/06, Robin Vickery wrote: On 28/06/06, tedd [EMAIL PROTECTED] wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: http://www.php.net/manual/en/language.operators.bitwise.php I wonder why that's true for php when it's common to use ^ in many other languages for powers? Perl: ^ is the bitwise xor operator Python: ^ is the bitwise xor operator C: ^ is the bitwise xor operator Java: ^ is the bitwise xor operator ... -robin Oh well, that settles it then. :-) 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] Calculations and exponents in languages
On 28/06/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Huh.. thanks for the illustration Robin. Can't say that I did much with exponents when I've played around with perl or python or C.. and never worked with Java. You've expanded my view. Ok, now what languages DO use ^ for exponents? The only one I can think of off the top of my head is BASIC. Even Bash uses ^ as an xor operator: $ echo $(( 7 ^ 2 )) 5 $ echo $(( 7 ** 2 )) 49 -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations and exponents in languages
Algol used ^ More common, historically, is the use of ** as the exponentiation operator: Fortran, PL/I, perl, python Curiously, many modern languages -- inexplicably -- don't have an exponentiation operator: C, Java, Javascript, PHP John Gunther Robin Vickery wrote: On 28/06/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Huh.. thanks for the illustration Robin. Can't say that I did much with exponents when I've played around with perl or python or C.. and never worked with Java. You've expanded my view. Ok, now what languages DO use ^ for exponents? The only one I can think of off the top of my head is BASIC. Even Bash uses ^ as an xor operator: $ echo $(( 7 ^ 2 )) 5 $ echo $(( 7 ** 2 )) 49 -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
Take a look at the pow() function http://php.net/pow - Frank Hi there list. Thanks for your help with my other questions. I was carrying on working through, and stumbled across a problem when trying to times something by the 'power' of something. By this I mean..in maths you can write 3 * (2 ^ 3), the answer to which would be 24. (as 2 ^ 3 = 8). The reason that I need this, is because I'm trying to double a variable x amount of times (x is set by another variable). For example my code is: $cost = $farm_cost * (2 ^ $farm_level); Any ideas how I would go about changing my calculation, as php dosn't seem to recognise ^ meaning 'to the power of'. Regards, Alex. -- 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] Calculations
At 6:26 PM +0100 6/27/06, Alex Major wrote: Hi there list. Thanks for your help with my other questions. I was carrying on working through, and stumbled across a problem when trying to times something by the 'power' of something. By this I mean..in maths you can write 3 * (2 ^ 3), the answer to which would be 24. (as 2 ^ 3 = 8). The reason that I need this, is because I'm trying to double a variable x amount of times (x is set by another variable). For example my code is: $cost = $farm_cost * (2 ^ $farm_level); Any ideas how I would go about changing my calculation, as php dosn't seem to recognise ^ meaning 'to the power of'. Regards, Alex. Try: pow(2,3) //8 $cost = $farm_cost * (pow(2,$farm_level)); 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] Calculations
Try: pow($base, $exp); http://us2.php.net/manual/en/function.pow.php Not sure why PHP doesn't use the ^.. havn't looked to see if it's already used for something else. -TG = = = Original message = = = Hi there list. Thanks for your help with my other questions. I was carrying on working through, and stumbled across a problem when trying to times something by the 'power' of something. By this I mean..in maths you can write 3 * (2 ^ 3), the answer to which would be 24. (as 2 ^ 3 = 8). The reason that I need this, is because I'm trying to double a variable x amount of times (x is set by another variable). For example my code is: $cost = $farm_cost * (2 ^ $farm_level); Any ideas how I would go about changing my calculation, as php dosn't seem to recognise ^ meaning 'to the power of'. Regards, Alex. ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Calculations
[snip] Any ideas how I would go about changing my calculation, as php dosn't seem to recognise ^ meaning 'to the power of'. [/snip] The first thing I would do is read http://www.php.net/math and follow the link to http://www.php.net/manual/en/ref.bc.php which would have me arriving at http://www.php.net/manual/en/function.bcpow.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Calculations
At 1:45 PM -0400 6/27/06, [EMAIL PROTECTED] wrote: Try: pow($base, $exp); http://us2.php.net/manual/en/function.pow.php Not sure why PHP doesn't use the ^.. havn't looked to see if it's already used for something else. -TG Yes, I found that surprising myself. BUT, I did find the answer in the manual. 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] Calculations
When my level of free time matches my level of curiousity, I'll have to research it further. For now, I'm ok with not knowing unless someone posts the answer here. hah -TG = = = Original message = = = At 1:45 PM -0400 6/27/06, [EMAIL PROTECTED] wrote: Try: pow($base, $exp); http://us2.php.net/manual/en/function.pow.php Not sure why PHP doesn't use the ^.. havn't looked to see if it's already used for something else. -TG Yes, I found that surprising myself. BUT, I did find the answer in the manual. tedd ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Calculations
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 2:11 PM To: php-general@lists.php.net Subject: Re: [PHP] Calculations When my level of free time matches my level of curiousity, I'll have to research it further. For now, I'm ok with not knowing unless someone posts the answer here. hah -TG Lucky day. ;) http://www.php.net/manual/en/language.operators.bitwise.php kgt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Calculations
Ahh.. thanks from the lazy programmer :) I knew I had seen it somewhere. Guess they ran out of symbols and decided XOR was more important than exponential operations. hah My vote would have been for ^ to remain for exponents and something overly complicated like |X| for xor..hah -TG = = = Original message = = = -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 2:11 PM To: php-general@lists.php.net Subject: Re: [PHP] Calculations When my level of free time matches my level of curiousity, I'll have to research it further. For now, I'm ok with not knowing unless someone posts the answer here. hah -TG Lucky day. ;) http://www.php.net/manual/en/language.operators.bitwise.php kgt ___ Sent by ePrompter, the premier email notification software. Free download at http://www.ePrompter.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Calculations
At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 2:11 PM To: php-general@lists.php.net Subject: Re: [PHP] Calculations When my level of free time matches my level of curiousity, I'll have to research it further. For now, I'm ok with not knowing unless someone posts the answer here. hah -TG Lucky day. ;) http://www.php.net/manual/en/language.operators.bitwise.php kgt Thanks. I wonder why that's true for php when it's common to use ^ in many other languages for powers? I can't remember the last time I used a bitwise operator for anything, but I have commonly used powers for the type of work I've done. But then again, I may be an exception. 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] Calculations
tedd wrote: At 2:30 PM -0400 6/27/06, Kristen G. Thorson wrote: -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 27, 2006 2:11 PM To: php-general@lists.php.net Subject: Re: [PHP] Calculations When my level of free time matches my level of curiousity, I'll have to research it further. For now, I'm ok with not knowing unless someone posts the answer here. hah -TG Lucky day. ;) http://www.php.net/manual/en/language.operators.bitwise.php kgt Thanks. I wonder why that's true for php when it's common to use ^ in many other languages for powers? I can't remember the last time I used a bitwise operator for anything, but I have commonly used powers for the type of work I've done. But then again, I may be an exception. tedd Lots of functions still use bit-based flags in PHP. Which is where OR comes in handy. Can't say I've used the others recently. XOR is handy on occasion, but doesn't really need an operator. Regards, Adam. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php