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

Regex/Javascript, convert strings with absolute values |x| to abs(x)

I'm trying to convert some math related strings containing absolute values, using Regex in Javascript. I would like to convert all occurences of |foo| to abs(foo). How can I detect if the character is opening or closing, given that they could also…
Appe
  • 3
  • 2
0
votes
1 answer

overflow in javascript arithmetic

i was reading a book , and encountered this Arithmetic in JavaScript does not raise errors in cases of overflow, underflow, or division by zero. When the result of a numeric operation is larger than the largest representable number (overflow), the…
polendina
  • 110
  • 3
  • 10
0
votes
2 answers

Python:absolute value of each element of a matrix inside a loop

In python (I am new working with python), I have a matrix built inside a loop in the following way: A[:,index_i ,index_j] = B[:,index_i ,index_j] - C[:,index_i ,index_j] Just after that inside the same loop there are some calculations on A, but…
FiSer
  • 27
  • 3
0
votes
1 answer

Compare excel sheets and highlight the differences if exceeding Certain value(Eg>=5)

I have 2 data frames df1 & df2, I am able to highlight the differences if the values are not equal(data.ne) But What I like to achieve is, to Highlight those parameters if the absolute difference between two data frames is (>=5) df_all = pd.concat…
SATHYA
  • 23
  • 5
0
votes
2 answers

recreation of absolute value finder not working as intended

I have scripted a code that gives the absolute value of any number here is the code: def absolute(num): numb = str(num) numb.replace("-","") numb = int(numb) return numb When used it gives an output of the same integer: >>>…
POINT ONE
  • 33
  • 1
  • 7
0
votes
3 answers

Java Method returns wrong value after left and right arithmetic bit-shifting

I have a method that looks like this: private short getAddress(short ir) { //performs bit shifting to isolate and find address short addr = ir; addr = (short) (addr << 11); //remove leading bits if (debug == true) { …
0
votes
1 answer

How can I compare values in 2D array with values in 1D array in GoLang?

I need to compare 1D array's and 2D array's values and to return the result array which has similar values using Go: func absolutePermutation(n int32, k int32) []int32 { var position []int32 var i, j int32 var result []int32 for i =…
0
votes
1 answer

I'm plotting absolute value functions in matplotlib and the graph just goes around the vertex

I'm trying to plot a function of f(X)= 2* abs(x-2)+4 but at the vertex or at point (2,4) the graph just stops and goes around it. Any way to change it so that it actually hits the point? thanks in advance. import matplotlib.pyplot as plt import…
0
votes
0 answers

Absolute value of a difference in gurobi with abs_() not working

I've got a problem with a gurobi program which is supposed to find a certain number of distinct shortest paths in a graph with a length not exceeding maxLength by using an LP. For making sure that the different paths are distinct I tried to sum up…
0
votes
5 answers

Find the maximum absolute value in a list

I'm looking to get the maximum absolute value in a random list. I need to create it in a function. I'm not sure what I'm doing wrong here. I have a for loop setup so it should check each number but it's only returning the first value. def main(): …
Doug
  • 29
  • 2
0
votes
0 answers

sympy integral wrong outside of values between 0 and 2pi for |cos x |?

I have come across strange outputs for sympy's integrate when it comes to |cos(x)| (I am restricting x to real numbers). Based on both the indefinite integral and definite integrals, sympy seems to gives correct results only for the [0,2pi] interval…
sphgy
  • 1
  • 1
0
votes
1 answer

Why is the character value gets subtracted from the given string

2 different strings were given and the question is to find out the minimum number of deletion from the given string to make both strings anagrams. I came to see this code snippet some where and all my test cases has passed, but could not understand…
Saranya
  • 69
  • 1
  • 4
0
votes
1 answer

How to count the numbers where the absolute value is greater than a cutoff with COUNTIFS in Excel?

I have the following numbers 12,34,-15,-23,-5,45,-50 and would like to find the count of numbers where the abs(x)>=15, which in this case is 5 Is this possible with the use of COUNTIFS ?
yathrakaaran
  • 179
  • 1
  • 3
  • 15
0
votes
2 answers

How to get absolute value in pyspark?

I am trying to run pyspark script. I am trying to find % difference between two count but not able to get the proper value. Can you please help me how to get this? Example: pre_count = 100 cur_count = 25 diff = (float((cur_count -…
Shivam
  • 213
  • 5
  • 14
0
votes
1 answer

complex h5 File to show

I have a complex type h5 file. 2d array. I want to imshow it. But I have following error. What is wrong? import h5py import numpy as np import matplotlib.pyplot as plt with h5py.File('obj_0001.h5', 'r') as hdf: ls = list(hdf.keys()) …
lighttn
  • 3
  • 1
  • 4