absolute-value Questions

2

How do I make a program that asks for one floating point number in Python and then calculates the absolute value? I've already tried the asking, but I can't make the line where it calculates the ab...
Shark asked 12/9, 2015 at 14:48

5

Solved

An absolute difference would be the absolute value of the difference between 2 numbers. Suppose I have 2 int variables (x and y) and I would like to find the absolute difference. An easy solution w...
Reddin asked 7/6, 2023 at 3:32

3

Solved

Numpy provides both np.absolute and the alias np.abs defined via from .numeric import absolute as abs which seems to be in obvious violation of the zen of python: There should be one-- and pr...
Bobseine asked 31/7, 2017 at 10:52

4

Solved

I have this list [1,-5,10,6,3,-4,-9] But now I want the list to be sorted like this: [10,-9,6,-5,-4,3,1] As you can see I want to order from high to low no matter what sign each number has, b...
Franzoni asked 5/10, 2013 at 16:26

4

Solved

In Go, why is there no function which directly calculates absolute value for integer datatypes? Currently all integer values have to be typecast to float64 and then passed to math.Abs(), which retu...
Impersonalize asked 25/8, 2019 at 19:5

16

Solved

Which is the fastest way to implement an operation that returns the absolute value of a number? x=root(x²) or if !isPositive(x): x=x*(-1) Actually this question can be translated as, how fas...
Phosphor asked 20/3, 2009 at 3:11

7

Solved

It appears, that in 32bit OS ip2long returns signed int, and in 64bit OS unsigned int is returned. My application is working on 10 servers, and some are 32bit and some are 64bit, so I need all the...
Boutis asked 16/5, 2009 at 13:19

2

Solved

How could I convert the values of column 'count' to absolute value? A summary of my dataframe this: datetime count 0 2011-01-20 00:00:00 14.565996 1 2011-01-20 01:00:00 10.204177 2 2011-01-20 02:0...
Brakesman asked 16/3, 2015 at 12:46

7

Solved

How can I convert a negative number to positive in Python? (And keep a positive one.)
Stonehenge asked 4/10, 2010 at 10:25

6

Solved

How do I get the absolute value of a number without using math.abs? This is what I have so far: function absVal(integer) { var abs = integer * integer; return abs^2; }
Dive asked 15/5, 2015 at 21:12

2

Solved

Both the RMSE and the MAE are ways to measure the distance between two vectors: the vector of predictions and the vector of target values. Various distance measures, or norms, are possible. General...

11

Solved

There's an array A containing (positive and negative) integers. Find a (contiguous) subarray whose elements' absolute sum is minimal, e.g.: A = [2, -4, 6, -3, 9] |(−4) + 6 + (−3)| = 1 <- minima...

2

Solved

I used the abs() function and I added #include <math.h> at the top of code. But I keep getting this error: hello.c:20:11: warning: implicit declaration of function 'abs' is invalid in C99 [-...
Ule asked 11/4, 2015 at 12:23

2

Solved

I ran some simple tests on abs() and fabs() functions and I don't understand what are the advantages of using fabs(), if it is: 1) slower 2) works only on floats 3) will throw an exception if us...
Marietta asked 24/2, 2014 at 16:58

4

Solved

I have the following script in Python. I am calculating the Fourier Transform of an array. When I want to plot the results (Fourier transform) I am using the absolute value of that calculation. How...
Assignation asked 19/7, 2020 at 17:45

9

Is there an abs() function in x86 assembly language? (This question originally mentioned getting the difference of 2 signed integers, but that's really a separate question if you need to do that wi...
Intrauterine asked 14/4, 2010 at 16:29

5

This was my try. For example df = pd.DataFrame({'a':[5,0,1,np.nan], 'b':[np.nan,1,4,3], 'c':[-3,-2,0,0]}) df.dropna(axis=1).max(axis=1,key=abs) Filters out well the NaN values but it gets 0 or n...
Phelan asked 7/12, 2015 at 10:24

8

Solved

This code: System.out.println(Math.abs(Integer.MIN_VALUE)); Returns -2147483648 Should it not return the absolute value as 2147483648 ?
Fistula asked 26/3, 2011 at 19:7

2

We got this problem at school for students that want to test themselves. I have spent quite some time on this but can't figure it out. You have 16-bit number in AX register, this number is sign...
Zurheide asked 12/4, 2020 at 21:0

4

Solved

How does this work? The idea is to make abs(x) use bitwise operators for integers (assuming 32 bit words): y = x >> 31 (x + y) ^ y // This gives abs(x) (is ^ XOR)?
Abandon asked 9/3, 2020 at 13:47

2

Solved

Consider a typical absolute value function (where for the sake of argument the integral type of maximum size is long): unsigned long abs(long input); A naive implementation of this might look so...
Elyseelysee asked 26/6, 2013 at 7:3

1

Solved

I want to get the absolute value of the following array: x = [1.1 -22.3 3.01, -1] i.e.: I want an output of the type: x2 = [1.1 22.3 3.01 1] However when I type: abs(x) I get an error: ERR...
Kab asked 27/12, 2018 at 10:29

9

Solved

In C/C++, why should one use abs() or fabs() to find the absolute value of a variable without using the following code? int absoluteValue = value < 0 ? -value : value; Does it have something ...
Samarium asked 4/2, 2018 at 14:17

2

I need to optimize a script that makes heavy use of computing L1 norm of vectors. As we know L1 norm in this case is just a sum of absolute values. When timing how fast numpy is in this task I fou...
Anastrophe asked 1/10, 2017 at 13:0

10

Solved

Is there any way to find the absolute value of a number without using the Math.abs() method in java.
Donadonadee asked 13/6, 2012 at 10:42

© 2022 - 2025 — McMap. All rights reserved.