Jump to content

Manipulating integers II


shamuraq

Recommended Posts

Hi all...

Thanx for all your responses regarding my query to manipulating integer. I have slight problem that i hope you can help me out with... How then do i convert a negative integer to a positive integer.

 

I'm doing an algebraic equation and i am very sure you already know that when you bring a positive integer over the other side of the equal sign (2x-3y + 6 = 0) they become a negative integer (2x-3y = -6) and vice versa.

 

Anyway proper syntax for this?

 

Link to comment
Share on other sites

Math in PHP works like the math you would normally use: -(-x) = x

 

I'm doing an algebraic equation and i am very sure you already know that when you bring a positive integer over the other side of the equal sign (2x-3y + 6 = 0) they become a negative integer (2x-3y = -6) and vice versa.

 

I suppose that it's a popular saying that you "move" it, but that's not really what's going on. You can perform the same operation on each side of the equal sign (except division and multiplication by zero). This means that if you have a=b, then a+x=b+x. 1=1 <=> 1+2=1+2 <=> 3=3. You just need both of the sides to evaluate to the same.

 

So if you have 2x-3y+6=0, then you know that subtraction is the opposite arithmetic operation of addition, thus they negate each other. So because of the above rules, you are allowed to say 2x-3y+6-6=0-6 <=> 2x-3y-0=-6 <=> 2x-3y=-6. You knew that you had to do -6 to get the +6, because that would make it +/-0, which is redundant so you can just remove it.

 

It helps to know that.

 

thanx Mchl...

but because i need to solve it later... does <echo> function store the output as variable or integer?

what do you think of:

 

$z4= -1*$z2;

echo $z4;

 

Please give me your comments...

 

echo is a language construct, and not a function. Either way, it takes a string as argument. PHP is weakly typed, so scalar non-string values will implicitly be converted to strings for usage in a string context. It's only converted for that purpose though and isn't stored anywhere.

Link to comment
Share on other sites

echo is a language construct, and not a function. Either way, it takes a string as argument. PHP is weakly typed, so scalar non-string values will implicitly be converted to strings for usage in a string context. It's only converted for that purpose though and isn't stored anywhere.

 

I swear i honestly wish i could fully grasp and understand your statement but i really appreciate the prompt attention i am getting from pros like you guys...

 

Thanx again Daniel and the gurus...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.