The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [integer]

Use this tag for questions about using, storing or manipulating integral values of all types and sizes, including concerns about overflow. Not for code that casually happens to use integers.

Filter by
Sorted by
Tagged with
2
votes
2answers
290 views

NSArray and NSNumber-int conversions

I have a textView which is displaying a string. I also have an array which keeps track of where every line begins, it stores the "start index" or NSRange.location for every line. However, when text ...
9
votes
2answers
18k views

Effectively convert little endian byte slice to int32

I have a data stream of bytes and I'd like to get a little endian encoded int32 from four bytes. Is there a better way than to do this like the following code? ...
2
votes
1answer
5k views

Get int array from database Cursor

I find this code quite ugly, but in fact, I can't find a finer way of achieving the goal. ...
5
votes
2answers
890 views

Improving a custom integer class 2.0

As sort of a follow up to my previous question from a year ago, what are some suggestions you can think of that will improve this code, whether is directly programming related or algorithm related? I ...
4
votes
2answers
308 views

Storing three integer values

Consider an 8-bit complier, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as: ...
6
votes
2answers
1k views

Integer to String recursive method

I was experimenting with lists, sets, and finally maps when I spotted a pattern in my code to make it recursive. Now I haven't used recursion much in the past or at work and I was very excited to have ...
30
votes
5answers
27k views

Int overflow check in Java

I have a piece of code that takes a couple of integers and check if performing an addition on the inputs would result in an overflow. I was wondering if this code is SOLID: ...
7
votes
2answers
7k views

Implementation of itoa()

How can this solution be improved? ...
10
votes
1answer
5k views

Converting a range of integers from a string to an IEnumerable

Goal Convert the following into an IEnumerable of integers accounting for the x-y ranges: ...
14
votes
2answers
18k views

Converting Roman numerals to integers and vice versa

...
7
votes
2answers
414 views

Writing data of a certain integer type to a buffer

I have function which writes data of a specified type to a buffer. Here is the part of this which writes Uint8, Uint16, ...
7
votes
3answers
2k views

Custom integer class for calculating crypto algorithms

How can I improve upon this integer class that I wrote? I am/will be using this for some calculation intensive crypto algorithms, mainly POLY1305AES. I might even write RSA using this. I know that ...
6
votes
2answers
2k views

Avoiding the 'possible loss of data' compiler warning

I'm writing a file I/O DLL in C++ which is going to be used from VB6. The interface is already fixed, and uses INT64/Currency as the general integer data type. Now I have this function: ...
7
votes
1answer
6k views

Combining two 32-bit integers into one 64-bit integer

long long combine(unsigned int high, unsigned int low) { return ((unsigned long long) high) << 32 || low; } Is there a better name for the operation? Is ...
7
votes
2answers
750 views

Terminating a C loop when maximum hardware limit reached

In response to the SO question C: f>0 vs Perl: $f>0?, the use of overflow to terminate the loop is referred to as "poor programming practice". Paraphrased: Your c code is actually exiting because ...
5
votes
4answers
281 views

Adjusting integer based on multiple elements in int array

I'm working with the following code which adjusts an int based on multiple elements of an integer array. I am wondering if there's a cleaner, easier-to-read construct for this: ...
5
votes
1answer
856 views

Branch-and-bound based IP solver

I've written this rather naïve branch-and-bound based IP solver. Are there any obvious JavaScript optimisations that could speed it up? I am not looking for asymptotically better algorithms, just ...