Questions tagged [number-systems]

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).

106 questions
130
votes
12 answers

Quickest way to convert a base 10 number to any base in .NET?

I have and old(ish) C# method I wrote that takes a number and converts it to any base: string ConvertToBase(int number, char[] baseChars); It's not all that super speedy and neat. Is there a good, known way of achieving this in .NET? I'm looking…
joshcomley
  • 28,099
  • 24
  • 107
  • 147
106
votes
5 answers

Why does Apache Commons consider '१२३' numeric?

According to Apache Commons Lang's documentation for StringUtils.isNumeric(), the String '१२३' is numeric. Since I believed this might be a mistake in the documentation, I ran tests to verify the statement. I found that according to Apache Commons…
Hannes
  • 5,002
  • 8
  • 31
  • 60
88
votes
16 answers

Algorithms based on number base systems?

I've noticed recently that there are a great many algorithms out there based in part or in whole on clever uses of numbers in creative bases. For example: Binomial heaps are based on binary numbers, and the more complex skew binomial heaps are…
templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
57
votes
15 answers

Displaying a number in Indian format using Javascript

I have the following code to display in Indian numbering system. var x=125465778; var res= x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); Am getting this output :125,465,778. I need output like this: 12,54,65,778. Please help me to sort out…
tilak
  • 4,589
  • 6
  • 34
  • 45
23
votes
11 answers

Checking to see if a string is an integer or float

So I'm creating a program to show number systems, however I've run into issues at the first hurdle. The program will take a number from the user and then use that number throughout the program in order to explain several computer science…
user6470150
11
votes
5 answers

Why does the range of int has a minus 1?

I read that the range of an int is dependent on a byte. So taking int to be 4 bytes long, thats 4 * 8 bits = 32 bits. So the range should be : 2 ^ (32-1) = 2 ^ (31) Why do some people say its 2^31 - 1 though? Thanks!
JoC
  • 243
  • 1
  • 4
  • 7
7
votes
0 answers

How to Convert Numbers into Indian Systems in Words/Strings

I am required to produce an accurate and reliable method for converting numbers into words for use in official document in the Indian Numbering System (as used in the countries of the Indian subcontinent). The result is supposed to be used for any…
7
votes
2 answers

Interconversion between decimal and any other base-n number system

I have written some general functions to convert between decimal and any other base-n number system(n<=36 for now) and vice-versa. Don't want to make things messy here so i have posted the code here. Could anybody suggest any better way for this?…
RubyDubee
  • 2,426
  • 2
  • 23
  • 34
6
votes
2 answers

C++ Find all bases such that P in those bases ends with the decimal representation of Q

Given two numbers P and Q in decimal. Find all bases such that P in those bases ends with the decimal representation of Q. #include using namespace std; void convert10tob(int N, int b) { if (N == 0) return; int…
VIVID
  • 555
  • 6
  • 14
6
votes
4 answers

How to convert string to int then to string?

I have tried to search for the duplicates of my problem, but could not find. Also, sorry for the not so understandable title. I am so confused about what I am searching, and also about the terminology. I am an electronics engineer with very little…
5
votes
6 answers

Java code to convert from Base-10 to Base-9

How to convert a long number in base 10 to base 9 without converting to string ?
Emil
  • 13,577
  • 18
  • 69
  • 108
4
votes
1 answer

How to find the xth decibinary number?

Hackerrank has a problem called Decibinary numbers which are essentially numbers with 0-9 digit values but are exponentiated using powers of 2. The question asks us to display the xth decibinary number. There is another twist to the problem.…
Ak01
  • 362
  • 3
  • 19
4
votes
1 answer

Floating point representation in number system

I don't know how to tackle this question, I know about explicit, implicit and IEEE-754 Normalized representation of floating point number but how to break it into small problem. Please help me to visualize it.
Sanjay Verma
  • 101
  • 13
4
votes
4 answers

How to find 10's complement of decimal number

Whats the 10's complement of 1056.074? Please check the solution: 9999.999 - 1056.074 = 8943.925 (9's complement of 1056.074) Now 1 is added to .074 or 8943?
user5011938
4
votes
3 answers

How to define a new number system in C++

Essentially what I'm attempting to do is create a base 62 number system in C++ (an alphanumeric number system -- one that includes a-z, A-Z, and 0-9). How would something like this be accomplished? I tried using a char array like this: const char…
1
2 3 4 5 6 7 8