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
-1
votes
3 answers

Two codes in python should be giving the same result but they don't

Description: The following codes recieves the coordinates of two dots with n dimensions. It calculates the manhanttan distance of theses two dots The codes: def manhanttan( ponto1, ponto2 ): totalp1 = 0 totalp2 = 0 for x in range( 0,…
Victor
  • 319
  • 2
  • 10
-1
votes
1 answer

function in mips that calculates the absolute value

hello i have an exercise in mips that must call a function to calculates the absolute value of a number i have write 2 codes but if you have any other solution write it .data message:.asciiz "give number: " .text main: li $v0, 4 la $a0,…
user2290590
  • 1
  • 1
  • 2
-2
votes
1 answer

Fastest way to calculate absolute values of a list

I have a question about calculating the absolute value of a list. I have written a short code to calculate the absolute value of each single element from a list and I was wondering if there is a faster way of doing this, Thanks! test_list = [5, -60,…
user18519249
-2
votes
2 answers

Getting absolute value from a binary int using bit arithmetics

flt32 flt32_abs (flt32 x) { int mask=x>>31; printMask(mask,32); puts("Original"); printMask(x,32); x=x^mask; puts("after XOR"); printMask(x,32); x=x-mask; puts("after x-mask"); printMask(x,32); …
-2
votes
4 answers

Decrementing an array and print a value if condition met

I want to decrement a pointer to the last element of an array and check for the condition that if the value of the pointer was smaller than 5, do nothing and go to the next round of loop and if not, that is if the value is equal or bigger than 5,…
Lucia
  • 901
  • 1
  • 11
  • 16
-3
votes
1 answer

I'm new to C, what does it mean when you make a variable equal to another variable and 0.0 at the same time?

Code provided in my lecture I'm very curious about how does the "term" variable work in the first line of code when it codes: double pi = 0.0, term; I also am unable to run this code on VSCode IDE Error Code C4578 I can't seem to find an answer on…
Calvin M
  • 13
  • 1
-3
votes
2 answers

How can I implement an absolute value operation?

How can I print the absolute value of a result? Example: |4-5| the result will be 1 (negative sign will be neglected) |5-4| this also have the answer of 1 (positive value remains as positive value)
Bharath R
  • 19
  • 1
-3
votes
4 answers

Why is this small C# program on SharpDevelop which uses 'for' loops not working?

I'm a complete beginner. I've written a small C# program on SharpDevelop. Here it is: double i, j; for(i=1; i<=30; i+=(1/60)) { for(j=1+1/60; j<=30; j+=(1/60)) { if(Math.Abs(Math.Log(i)/Math.Log(j)-0.63092975357)<=0.00001) …
user50746
  • 281
  • 2
  • 4
  • 10
-3
votes
7 answers

How to display position: absolute div once it has display: none attribute

i have a following div
Then i hide it via JS with display none. Is it possible to display it back again? None of the…
azza idz
  • 623
  • 3
  • 13
  • 27
1 2 3
14
15