Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to express the variable in absolute value form

'This is the variable which I want to express in absolute value .

<%= rate-32.5   =%>

However ,I tried

<%= |rate-32.5  |=%> 

It doesn't work .

And I guess there is no this method in ruby .

like image 821
Monchhichi Avatar asked Feb 11 '17 04:02

Monchhichi


People also ask

How do you write an absolute value expression?

More generally, the form of the equation for an absolute value function is y=a| x−h |+k.

How do you find the absolute value of a variable?

To solve an equation containing absolute value, isolate the absolute value on one side of the equation. Then set its contents equal to both the positive and negative value of the number on the other side of the equation and solve both equations. Solve | x | + 2 = 5. Isolate the absolute value.

What is an example of an absolute value expression?

Examples of absolute value expressions or expressions containing one or more absolute value signs, include: |7 - 8 x 4| + 6. 3|6 - 2 x 2| - |-5|

What is absolute value form?

The general form of an absolute value function is f(x)=a|x-h|+k. From this form, we can draw graphs.


1 Answers

Use this link for more details of .abs ruby method.

abs → numeric

Returns the absolute value of num.

  12.abs              #=> 12

  (-34.56).abs        #=> 34.56

  -34.56.abs          #=> 34.56

So you use .abs function for your solution like this (rate-32.5).abs

like image 104
Manoj Kumar Avatar answered Sep 24 '22 02:09

Manoj Kumar