Questions tagged [negative-number]

A negative number is a number that is less than 0. It is signified by a preceding hyphen (i.e. -12,345).

This tag should be used for any questions dealing specifically with negative numbers.

599 questions
-1
votes
2 answers

Floating Point representation for negative numbers

Using.... sign bit of mantissa 8 bit exponent in two's complement 23 bit mantissa code the following: -28.625 Can someone show me the easiest way to do this...lecturer wasn't very helpful!
-1
votes
2 answers

Reading a number from the user

I want to read a positive integer from the user. If the user enters something else, I want to ask again. I did it when the user entered a negative number. But if the user enters a character or anything else, what should I do? int main (){ …
Mr.Gurbuz
  • 29
  • 5
-1
votes
1 answer

Bootstrap 3 input spinner with negative values

I am coding a MVC 5 internet application and am wanting to add an input spinner control for my integer values in my MVC views. I have looked on the Bootstrap 3 website and cannot find a spinner control. I am wanting the input spinner to be able to…
Simon
  • 7,991
  • 21
  • 83
  • 163
-1
votes
3 answers

convert negative decimal number to binary number

I tried to convert a negative decimal number into a binary number and this code perfectly works on my computer, but the code doesn't work another computer. I didn't get how it is possible. What is wrong in my code? #include #include…
bendensin
  • 31
  • 1
  • 4
-1
votes
2 answers

I am trying to change the sign of a number to negative if it is below a specific target and it is to remain positive if it is above.

I put the section of code in bold that seems to be the problem. Here is the code: ## price impact analysis rm(list=ls()) ### import data from excel spreadsheets chtr_trades <- read.csv("F:/FRE 6951 Mkt Micro Struc/CHTRTRADES.csv") chtr_quotes <-…
Drazen
  • 67
  • 1
  • 1
  • 12
-1
votes
2 answers

Effects of the negative bit

How does the negative bit work? Why does the negative bit allow negative numbers to have an absolute value 1 greater than positive ones (two's compliment)? Why isn't this bit read in as 2^x, where c is the number of bits? I just don't understand,…
user3897320
  • 87
  • 1
  • 2
  • 7
-1
votes
2 answers

How can R considers a string as negative?

Please consider the following string_1 = "??????????" string_2 = " bob" string_3 = "_bob_" string_1 < 0 # [1] TRUE string_2 < 0 # [1] TRUE string_3 < 0 # [1] TRUE but string_4 = "bob" string_4 < 0 # [1] FALSE Why a string is considered as a…
CptNemo
  • 6,455
  • 16
  • 58
  • 107
-1
votes
1 answer

MySQL sum with negative decimals

I have a qty column in my table, and i'm trying to sum the values. The field type is varchar(20). The sum of qty below should add up to exactly 0. It's a mix of negative and positive decimals. exhibit A (screenshot) When i perform the sum below,…
drschultz
  • 157
  • 1
  • 2
  • 12
-2
votes
4 answers

Calculate the maximum number of the three in javascript

This is my code, and it works, but only with positive numbers. If I write nothing into the input it considers as value 0, and this is a problem if I have only one or two negative numbers. function Calculeaza() { var a =…
-2
votes
2 answers

How to reduce negative fractions in Javascript

I have seen this question but it doesn't work for negative numbers or numbers with (+) prefixes. Here's what I want. -20/8 = -5/2 +28/-6 = -14/3 -30/-4 = 15/2 34/12 = 17/6 +40/6 = 20/3 32/+64 = 1/2
DavidNyan10
  • 163
  • 13
-2
votes
1 answer

Python: Average of Non-Negative numbers

def test(): # do not change this or the next line! numbers = [11.5, 28.3, 23.5, -4.8, 15.9, -63.1, 79.4, 80.0, 0, 67.4, -11.9, 32.6] average = 0 # I need to write my code here so that it sets average # to the average of the…
-2
votes
2 answers

Java for loop is negative

When you run below code The count value becomes -1 and the program ends up with divide by zero exception. When you uncomment the sysout, it runs fine. Not sure how sysout makes a diference. public class HelloWorld{ public static void…
Kris
  • 719
  • 1
  • 11
  • 19
-2
votes
3 answers

why if I enter a negative number in the method, condition else if does not catch it

I have problem with solution in this example. Input:>6 Output:0+1+2+3+4+5+6 = 21 Input:> -15 Output:-15<0 Input:>0 Output:0=0 public static string ShowSequence(int n) { int sumInt = 0; string sum = ""; for (int i = 0; i <= n;…
Kajman
  • 13
  • 3
-2
votes
2 answers

Java FileOutputStream writing negative byte values writing wrong bytes

I came to a problem with writing negative byte values into binary file using FileOutputStream, where negative byte values, ex. -1 is written into file but it takes there two bytes and they seem to me to be completely nonsense. In my application I…
El El
  • 27
  • 5
-2
votes
2 answers

How to make a for loop keep returning values?

I have to set up two loops. One that keeps totaling the number of negative numbers in a list and is returned. Another that appends the negatives to a separate list to also be returned. I have only been able to return the first value in each loop. #…
user294506
  • 23
  • 3