Questions tagged [absolute-value]

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

Absolute value is a mathematical function that returns the non-negative value of a number without regard to its sign.

For example, both 7 and -7 will have an absolute value of 7.

Many programming languages include a function for absolute value in their standard math libraries, often named abs() or similar.

More information: http://en.wikipedia.org/wiki/Absolute_value

219 questions
0
votes
1 answer

Match absolute value and return whole column EXCEL

We have a row with indicative numbers from which two largest absolute values are extracted. Under these indicative numbers we have data spanning to n rows. Now we'd like to get the rows for each of those largest indicative values. For example: -1.6…
AK88
  • 2,946
  • 2
  • 12
  • 31
0
votes
1 answer

Assembly array absolute value

I am trying to write assembly procedure which receives a parameter in register ebx, and returns the absolute value of the parameter in register eax, then calling that procedure in a loop to visit every elements of a given array and to get their…
mwater07
  • 131
  • 4
  • 14
0
votes
1 answer

Return ABS value from formula using Excel VBA

In the code given below, that was orchestrated by Robin Mackenzie, I am now trying to get the absolute value from the equation. I tried using the ABS() command: .Formula = "=IF(ISNUMBER(" & strLowLimCol & "2)," & _ strMeasCol &…
Joe
  • 357
  • 2
  • 10
  • 32
0
votes
1 answer

Abs and using namespace std

Say I am using using namespace std (undeniably bad practice) and that I use the abs function in my code (to get the overloaded absolute function). To be specific my MWE is: #include #include #include using namespace…
MaviPranav
  • 335
  • 2
  • 14
0
votes
2 answers

How to use a number given in a string to calculate the absolute value?

So I am writing a program where I ask the user to enter a number and then I return the absolute value of that number. My program should allow + or - sign. (or none) And also a number with or without a decimal point. Since I'm a beginner I don't want…
tziroldo
  • 1
  • 2
0
votes
9 answers

How to convert this value into absolute value?

I am getting this from webservice "rateavg": "2.6111" now i am getting this in a string. How to do this that if it is coming 2.6 it will show 3 and if it will come 2.4 or 2.5 it will show 2 ? How to get this i am not getting. please help me
user6438311
  • 117
  • 1
  • 3
  • 13
0
votes
2 answers

Compute the absolute number of minutes between two (or more) clock times

Given the following two character vectors composed of times in the format “%H:%M”: Time1 <- c("23:00","23:59","00:01", "01:00") Time2 <- c("00:00"," 00:00","00:00", "00:00") How can I compute the absolute distance between the times such that my…
0
votes
1 answer

Calculate absolute difference between values in two columns

I'm writing a R code to count/select the rows with absolute difference of two values in two columns less than a certain value (say 0.1). It reads two files and two column numbers, based on which the calculation is done.…
olala
  • 4,146
  • 9
  • 34
  • 44
0
votes
2 answers

How can I locate the element of an array that is nearest to some number?

I have an array A, e.g. A = [-79.0732 -82.1919 -85.0432 -87.0406 -90.0102 -92.6745] and some number x (e.g. -90), and I want to find the index of the element in the array that is closest (in absolute value) to x. In my example, the element…
0
votes
1 answer

How many non diagonal moves from origin point?

87 76 67 58 49 40 31 22 13 4 77 68 59 50 41 32 23 14 5 -4 69 60 51 42 33 24 15 6 -3-12 61 52 43 34 25 16 7 -2-11-20 53 44 35 26 17 8 -1-10-19-28 45 36 27 18 9 0 -9-18-27-36 37 28 19 10 1 -8-17-26-35-44 29 20 11 2 -7-16-25-34-43-52 21 12 3…
Medullan
  • 55
  • 1
  • 2
  • 8
0
votes
1 answer

Overcoming an n^2 runtime program

Is there a way to overcome a nested loop recursion in C++11? My program has a slow runtime. Or rather, is there a more efficient way to solve for the following formula z=|a-b|*|x-y|,with a, b, x and y being elements in a 10000 integer array? Here…
0
votes
2 answers

How to display an absolute value

Given the following code: IDENTIFICATION DIVISION. PROGRAM-ID. FABS. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 NUM PIC 9 VALUE ZEROS. 01 ABSVAL PIC 99 VALUE ZEROS. PROCEDURE DIVISION. PROGRAM-BEGIN. …
MCMLXXXIX
  • 23
  • 2
  • 6
0
votes
4 answers

How could I efficiently make a number's absolute value closer to zero?

I know one possible way of achieving this: int a = 7; int b = -10; public int makeSmaller(int num) { int result = Math.abs(num) - 1; if(num > 0) return result; else return -result; } makeSmaller(a); //returns 6 makeSmaller(b); //returns…
AJ Weeks
  • 29
  • 6
0
votes
2 answers

Absolute value java

I am trying to create a directory with the name of the absolute value of the hexadecimal version of a hashed url, using the built-in hash() method of the String class. Now it is possible for hash() to produce a negative result, and a directory name…
Gio
  • 15
  • 7
0
votes
2 answers

How to calculated the absolute value via of bit operations

In the Hacker's delight, there is an example of calculating the absolute value of x as (х XOR (x >> 31)) - (x >> 31). I know that x >> 31 returns the sign of x. I understand Boolean algebra, but how does (х XOR (x >> 31)) - (x >> 31) work?
user1886376