Skip to main content

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
3 votes
2 answers
844 views

Intro In this post, I will present three (3) non-negative integer encoding techniques: Elias gamma coding Elias delta coding Golomb-Rice coding Code ...
coderodde's user avatar
  • 32.2k
5 votes
2 answers
849 views

Intro This time, I have attempted to prove the following bruteforce multiplication formula: $$ (a_n \cdots a_0) \cdot (b_m \cdots b_0) = \sum_{i = 0}^n \sum_{j = 0}^m a_i b_j \cdot 10^{i + j}, $$ ...
coderodde's user avatar
  • 32.2k
-4 votes
1 answer
393 views

[edit] Hint: a similar project for C++20 which - as far as I see - also manages bigger than 128-bit integers can be found at: Infinite precision integer in C++20 . [/edit] I got lots of kind hints on ...
user1018684's user avatar
3 votes
1 answer
253 views

An update to Int128 That is built on Linux for lack of direct support, based on System.Numerics Nuget package. ...
Short Int's user avatar
  • 762
4 votes
1 answer
247 views

I have created Int128 which is based off of BigInteger with operator overloading to handle larger math requirements. Here is a ...
Short Int's user avatar
  • 762
3 votes
0 answers
130 views

I have this repository. It contains three variations of a simple sorting algorithm for integer keys. The idea is that we keep a balanced BST in which each node holds the integer key and its frequency. ...
coderodde's user avatar
  • 32.2k
2 votes
1 answer
186 views

As Java programmers, we can always use the BigInteger isProbablePrime() method or store manually all prime numbers in a HashMap. This question is about the most efficient way to figure out if a single ...
user3595831's user avatar
3 votes
2 answers
337 views

This is a follow-up question for conv2 Template Function Implementation for Image in C++ and An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. For performing ...
JimmyHu's user avatar
  • 7,575
9 votes
3 answers
1k views

I'm learning C and as exercise I'm trying to implement a custom function to parse a input from user and return successfully only if the input is a number. These are my files, how could I improve it? ...
shark_sh's user avatar
1 vote
1 answer
174 views

Problem: According to a recent survey, Biryani is the most ordered food. Chef wants to learn how to make world-class Biryani from a MasterChef. The chef will be required to attend the MasterChef's ...
kvk30's user avatar
  • 113
3 votes
1 answer
146 views

This class is meant to work exactly as an unsigned integer should work, but it limits the value based on a set amount of bits. ...
RhinoRunner's user avatar
0 votes
1 answer
43 views

I would like to refactor the following code snippet adapted from a project I'm involved. It is part of a code to control power outlets via network. The code snippet was written by myself based on the ...
Looser User's user avatar
6 votes
2 answers
213 views

I made a borders filter in C. It works properly, but I think it could be optimized and better designed; the formatting is abysmal. It uses too many lines for the border cases and has too many ...
GBA's user avatar
  • 63
1 vote
3 answers
219 views

I've a simple push/pop implementation in my program: ...
3rdgrade-dropout's user avatar
3 votes
1 answer
383 views

I have implemented an integer square root function that is branch-free and runs in constant time, using the first variant found in this answer as a base. All possible values for the types ...
Kittoes0124's user avatar
  • 1,960
8 votes
4 answers
3k views

If this code is written correctly, it will block undefined behavior from happening in the case of signed overflow (guaranteeing that the program halts instead), and also guarantee that the program ...
Thisis Afal Sename's user avatar
4 votes
1 answer
711 views

Is it a bad thing to use asserts to validate user inputs? Or should I keep using an if statement in case the number isnt positive? Code with assert statement: ...
eddyxide's user avatar
  • 141
6 votes
4 answers
2k views

This code was a challenge from a friend. Essentially she wanted a way to "Divide an even number into 2 even numbers." So I made this quick and dirty Python program to find the solutions up ...
Omar Morales Rivera's user avatar
5 votes
2 answers
1k views

The problem goes like this: Given two one-dimensional arrays, for example a = (3, 4, 5) and b = (5, 6, 9), write a function ...
Eugene Yarmash's user avatar
5 votes
4 answers
2k views

(See also the next iteration.) I have rolled this short program that converts int values to the human readable strings: ...
coderodde's user avatar
  • 32.2k
0 votes
1 answer
246 views

The context is a library to represent numbers (in this case integers) by wheighted position by radix powers for every radix R, passed as template argument. These derived types are digits of radix R, ...
Earendil's user avatar
2 votes
1 answer
250 views

I want to encode a non-negative integer to ASCII letters and digits. I wrote below code for that, that works, but which I assume too immature to use in production. ...
user avatar
3 votes
1 answer
3k views

I need to format a number with space as thousand separator in my Java code for Android. How can these functions be improved? What are the pros and cons to the first recursive method? What are the ...
Ola Ström's user avatar
4 votes
3 answers
1k views

I wanted to get my code reviewed as I have tried to implement a basic Money class to represent money values in c++. Can anyone tell me if I am implementing my basic arithmetic operator overloads ...
paigelarry342's user avatar
0 votes
3 answers
931 views

...
nates7's user avatar
  • 1

1
2 3 4 5
8