#### Archived

This topic is now archived and is closed to further replies.

# math operator ...

This topic is 5648 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

many times i have seen somthing incaplulated with ''|'' what does this meen ? *like : |A| * or * |V| * can anybody explain this ?

##### Share on other sites
It means the absolute value of the value encapsulated between the |'s. That is, |V| == abs(V) where

float abs(float x){
if (x<0) return -x;
else return x;
}

In C/C++ code, | means bitwise or (|| = logical or).

Edit: woops... the next poster is right

[edited by - Kurioes on January 5, 2003 2:05:39 PM]

##### Share on other sites
Ok, I am a bit tired, so my mind might be messed up, but isn''t you abs() function a bit weird.
It could as well just say "return x;" since that is all it does...

Isn''t this the correct way:

  float abs(float x){if(x < 0)   return -x;else   return x;}

Simplier put, it is as this:
x = 10
|x| = 10

y = -5
|y| = 5

If the number is negative, then just remove the "-"-sign.
The absolute value is actually just the size of the number, not considering which direction it is facing (well, mostly we just delas with 1 dimension, and then you have negative and positive numbers, but if you count in 2 dimensions, then |x| would be the size of your 2d-value (actually, it is the length of a line...).

##### Share on other sites
Also note that if V is a vector, then |V| is the length of the vector.

##### Share on other sites
It also means the length of a vector, ie if you have a vector:

v(x, y, z)

then |v| =

sqrt( x^2 + y^2 + z^2 )

Which is defined as the absolute value operation on a vector, it''s just a bit more of a calculation than the above answer (which is correct) for a scalar number..

##### Share on other sites
Mathematically, |V| is equivalent to sqrt(V2).

Cheers,

Timkin

[edited by - Timkin on January 5, 2003 5:55:34 PM]

##### Share on other sites
It can also mean the determinant of a matrix.

##### Share on other sites
quote:
Original post by Timkin
Mathematically, |V| is equivalent to sqrt(V2).
[edited by - Timkin on January 5, 2003 5:55:34 PM]

This is only true for real numbers.

##### Share on other sites
quote:
Original post by Predictor
This is only true for real numbers.

Okay... I had assumed we WERE discussing reals (scalar and vector), as opposed to say complex numbers or matrices.

I would have assumed that the distinction was rather obvious and didn''t need further clarification!

Timkin

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×