Combine integers into a long

I need to somehow concatenate a series of 8 integers into a single long in Java. The values of the integers are between 0-255. They have to be combined in this manner: Lets say we got this sample of integers (in binary): 00000000 00000000 00000000 1...
more »

2017-04-19 20:04 (3) Answers

Objective C Int to 2's Complement Conversion

I'm trying to convert my 16 bit integer to two's complement if it's negative. At the moment, I'm using the One's complement operator. I figure I can use that, and then add 1 to the binary value to convert it to two's complement. However, I'm unable...
more »

2017-04-19 18:04 (1) Answers

using scanf to enter integers only?

I have been working on a program which requires integer inputs, but every time a non-integer is accidentally entered, the scanf function stops working or becomes stuck in a loop. This is an example of what I tried to do: int n; printf("plea...
more »

2017-04-18 22:04 (2) Answers

Looping with double vs int

I am trying to figure out why i get two different outputs for seemingly similar loops. I think it has something to do with looping with doubles versus ints, but I am not sure. This code outputs 4: int num = 10; int cost; int counter = 0; for (cos...
more »

2017-04-18 03:04 (1) Answers

Find element that appears odd number of times

I'm trying to solve this exercise of finding the number that appears an odd number of times in an array. I have this so far but the output ends up being an integer that appears an even number of times. For example, the number 2 appears 3 times and th...
more »

2017-04-18 00:04 (4) Answers

Python: Only return integers

I want to find the prime factors for 13195. for num in range(1,13196): x = 13195/num I want x to only store integers. I've tried is.integer and but keep getting syntax errors. ...
more »

2017-04-17 19:04 (2) Answers

Representing an Integer in bits : Error

I am trying to declare an integer in bytes. What i mean is : i am trying to declare int a = 4 as int a = 0100(i have shortened it here to 4 bits for simplicity. ) Following is the code which i have used and is giving me unexpected output. public c...
more »

2017-04-17 10:04 (1) Answers

Can't change string to int in php

I am trying to change a variable of type string to integer, before doing next manipulation, but something going wrong: ob_start(); ... //some code $notices = ob_get_contents(); ob_end_clean(); then, trying to change it, but all this don't work: e...
more »

2017-04-16 15:04 (0) Answers

Reversing order of integers in an Array

I have this problem below. I am trying to complete a program that reads multiple input from the user to form an array, then outputs the array in reverse order. First line of input n should be the number of integers in the array. The next input shoul...
more »

2017-04-15 20:04 (2) Answers

While loop with integers not working

#include <iostream> using namespace std; int main(){ int integer=400; int count=1; while (count == integer){ cout<< count<<endl; count = count + 1; } } This is basically what I used on my project. Seems to give no output. Hel...
more »

2017-04-15 16:04 (2) Answers

Transform string in integer

i'm having trouble transforming string values into integers in CSV in python so i can store it in mongodb. i'm working on a database of over 100000 documents, and it doesn't recognize some fields as integers as they should be, so i can't do some quer...
more »

2017-04-14 10:04 (0) Answers

java weird assignment rules

short s = 'a'; // valid Short ss = 'a'; // valid int i = 'a'; // valid Integer ii = 'a'; // invalid Why Integer ii = 'a' invalid, but int i = 'a' valid? Why Short ss ='a' valid, but Integer ii = 'a' invalid? another set qu...
more »

2017-04-13 20:04 (1) Answers

How to check is an input is a float of not

I am currently working on some code to tell wether my users input is a float or integer but it doesn't seem to be working can anyone help? number = input ("Enter something:") if type(number) != int: print("Isn't a whole number") else: ...
more »

2017-04-10 18:04 (1) Answers

Check for double integers in group

I have 64 integers in a magic square ranging from Label1 to Label64. How can I easily check if any two(or more) of these integers are equal to each other, since double numbers are not allowed in a magic square? Thanks in advance for any help! Lang...
more »

2017-04-08 15:04 (1) Answers