9
$\begingroup$

How to convert any number (negative or positive) into a positive number.. For example, my input can be 4545 or -4545, I need the out come to be positive value 4545.

$\endgroup$
1
  • 1
    $\begingroup$ This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. $\endgroup$
    – dustin
    Jan 6 '15 at 1:47
11
$\begingroup$

You just have to simply multiply by $-1$. For example if you have a number $-a$ then multiply by $-1$ to get $-a \times -1 =a$. If the number is positive then multiply by $1$.

Or if you are aware of the Absolute Value, then take the absolute value of the number.

$\endgroup$
2
  • 2
    $\begingroup$ This is the problem. I am getting the first value from an equation. I do not know it would be positive or negative. But I want it in positive. So I need to apply some equation on it if I am right. $\endgroup$
    – Muneer
    May 28 '11 at 7:04
  • $\begingroup$ cool. Absolute Value is working. $\endgroup$
    – Muneer
    May 28 '11 at 7:11
13
$\begingroup$

With a calculator, you could make a number positive in one of two (simple) ways:

  • $\text{abs}(x)$
  • $\sqrt{(x^2)}$

The first one is recommended, but the second one will work as well as the square root function on most calculators returns the positive root. Squaring a real number always makes it positive, so taking the square root of a number squared returns the positive number.

$\endgroup$
6
  • 2
    $\begingroup$ Yes, by all means use $\operatorname{abs}(x)$! You don't want to waste time squaring and taking roots (you'll also have to cope with imprecisions)... $\endgroup$
    – t.b.
    May 28 '11 at 7:10
  • 1
    $\begingroup$ Precisely. The second option is a work-around only (like if your calculator doesn't have an absolute-value function). $\endgroup$ May 28 '11 at 7:12
  • 2
    $\begingroup$ In textbooks, the first one is often written $\lvert x\rvert$. $\endgroup$
    – FUZxxl
    May 28 '11 at 8:57
  • $\begingroup$ no, square root give two results: +/- $\endgroup$
    – Serg
    May 30 '18 at 6:57
  • 3
    $\begingroup$ @Sergei: to be pedantic, the square root symbol always means the principal square root, which is positive. $\endgroup$ May 30 '18 at 12:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.