Anything related to number systems, i.e. the way of representing numbers (the abstract mathematical entities) as finite sequences of symbols. Usually this tag is relevant on questions involving conversion from the representation in a number system to another (e.g. from decimal to binary).
Questions tagged [number-systems]
106 questions
4
votes
1 answer
Convert integer to base 26, using a to z as digits
I need to implement a decimal to chars converter. I have 26 chars available, so it's about converting an integer to base 26 system and then, changing each number to it's alphabet counterpart. I don't want to use the characters 0-9 in the final…

mbajur
- 4,406
- 5
- 49
- 79
4
votes
2 answers
Octal representation inside a string in C
In the given program:
int main() {
char *p = "\0777";
printf("%d %d %d\n",p[0],p[1],p[2]);
printf("--%c-- --%c-- --%c--\n",p[0],p[1],p[2]);
return 0;
}
It is showing the output as:
63 55 0
--?-- --7-- ----
I can understand that it is…

r.bhardwaj
- 1,603
- 6
- 28
- 54
4
votes
5 answers
Best way to store large base B numbers?
What is the best way to store large base B numbers so that the operations like right shift and checking the least significant bit can be done efficiently?
Actually, I have came across an interview question which says that
Given two numbers N and K…

Ravi Gupta
- 6,258
- 17
- 56
- 79
3
votes
1 answer
Universal number system conversion to decimal with udl
I'm trying to create a universal conversion function which aims to convert base-any numeral system to decimal:
namespace detail
{
template constexpr auto
toDecImpl()
{
return Chs > '9' ? Chs - 'A' + 10 : Chs - '0';
…

Chen Li
- 4,824
- 3
- 28
- 55
3
votes
5 answers
How does int(x[,base]) work?
The output for the following code is:
int("12", 5)
O/P: 7
int("0", 5)
O/P: 0
int("10", 2)
O/P: 2
I cannot make sense of this. From the Python documentation it says: The "[, base]" part is optional i.e it might take one or two arguments.
The…

Manshi Sanghai
- 283
- 2
- 3
- 10
2
votes
2 answers
Is it possible to change number systems in python?
This may sound similar to many other questions, but I couldn't find an answer to mine. I'm wondering if you can switch the number system of any number. For example,
x = 10
y = int(10, 3)
How can I switch x into a base-3 number system? This is the…

help
- 61
- 5
2
votes
2 answers
Understanding One's Complement
I just have a quick question regarding one's complement with binary numbers that maybe someone could help me understand.
I am studying for a computer security test and I am practicing converting decimal numbers to binary numbers and then using one's…

Cory Freeman
- 21
- 3
2
votes
1 answer
The complexity of carry-free addition
Two binary numbers can be represented in the usual "regular, redundant" representation (i.e. introduce another digit, say 2, to obtain a non-unique representation such that any two consecutive 2's have a zero in between), so that addition becomes…

user616847
- 23
- 2
2
votes
1 answer
Custom number system in C#
I have a requirement for a custom number system in C# which goes as following:
A - 1
B - 2
...
Z - 26
AA - 27
AB - 28
I've made a function that converts from arbitrary strings to numbers like this:
private const int Min = 'A';
private const…

Alxandr
- 12,345
- 10
- 59
- 95
2
votes
3 answers
How to localize number system in Java e.g. in Hindi or in Marathi?
I use JSTL tag with properties file to localize text on the JSP. The texts for different languages are kept in their respective properties file associated with a key.
Then that key is used in JSP like,
How…

ajm
- 12,863
- 58
- 163
- 234
2
votes
4 answers
Track first digit during a long multiplication in c
I have an array of integer element range up to 10^5, and I have to find the first element after the total multiplication.
Example:
Array : 2,4,6,7
multiplication result: 336 and the first element is 3.
Obviously I cannot multiply the elements…

Mayur Kharche
- 717
- 1
- 8
- 27
2
votes
2 answers
Python: How to convert a number which ll separated by comma as number count increases?
I have a number like: 100 I am showing here as it.
But when I am trying to show a number as 1000 then want to display as 1,000.& so on like 1,00,000 likewise.
Below structure
Number Formatted As
10 10
100 …

danny
- 983
- 1
- 7
- 13
2
votes
0 answers
Incorporate repetition-detection in my p-adic arithmetic loops?
I'm implementing arithmetic functions for numbers in a quote notation representation, which is a form of p-adic numbers. Taking the basic idea from this paper, I have a struct and a constructor.
enum { base = 10 };
/*
d[n+m-1] ... d[n+1] d[n] '…

luser droog
- 18,988
- 3
- 53
- 105
2
votes
1 answer
Number system convertion with Recursive function - Error in return value
I have to make a program where I have to convert numbers from the decimal system into another one (base 2 to 9), like in my first question.
But this time I have to make it using a recursive function. So I came with:
function cambiarBase(n,b:…

LeoAM
- 109
- 1
- 8
2
votes
1 answer
Base conversions: issue with fractions
I have written a system that is able to convert any base (2-36) to another base with whole numbers, and it can convert any real number from base 10 to any other base (2-36).
My problem arises with converting a rational/irrational number from any…

bgroenks
- 1,859
- 5
- 34
- 63