Questions tagged [radix]

In mathematical numeral systems, the radix or base is the number of unique digits, including zero, that a positional numeral system uses to represent numbers. For example, for the decimal system (the most common system in use today) the radix is ten, because it uses the ten digits from 0 through 9.

178 questions
602
votes
11 answers

JSLint says "missing radix parameter"

I ran JSLint on this JavaScript code and it said: Problem at line 32 character 30: Missing radix parameter. This is the code in question: imageIndex = parseInt(id.substring(id.length - 1))-1; What is wrong here?
Mike Vierwind
  • 6,189
  • 3
  • 13
  • 9
241
votes
27 answers

How to convert an integer to a string in any base?

Python allows easy creation of an integer from a string of a given base via int(str, base). I want to perform the inverse: creation of a string from an integer, i.e. I want some function int2base(num, base), such that: int(int2base(x, b), b) ==…
Mark Borgerding
  • 7,087
  • 3
  • 26
  • 50
194
votes
3 answers

Why is it that parseInt(8,3) == NaN and parseInt(16,3) == 1?

I'm reading this but I'm confused by what is written in the parseInt with a radix argument chapter Why is it that parseInt(8, 3) → NaN and parseInt(16, 3) → 1? AFAIK 8 and 16 are not base-3 numbers, so parseInt(16, 3) should return NaN too
Devid Farinelli
  • 7,020
  • 8
  • 35
  • 65
122
votes
10 answers

How to convert a Binary String to a base 10 integer in Java

I have an array of Strings that represent Binary numbers (without leading zeroes) that I want to convert to their corresponding base 10 numbers. Consider: binary 1011 becomes integer 11 binary 1001 becomes integer 9 binary 11 becomes integer 3 …
dwwilson66
  • 6,086
  • 27
  • 66
  • 106
30
votes
3 answers

Using Javascript parseInt() and a Radix Parameter

Can anyone explain how the parseInt() functions works and what the Radix Parameter is? As a case study, I am trying to get to grips with this code snippet: var maxChars = parseInt( formField.attr('maxlength') ? formField.attr('maxlength') :…
shrewdbeans
  • 9,979
  • 19
  • 59
  • 108
24
votes
6 answers

What is the radix parameter in Java, and how does it work?

I understand that radix for the function Integer.parseInt() is the base to convert the string into. Shouldn't 11 base 10 converted with a radix/base 16 be a B instead of 17? The following code prints 17 according to the textbook: public class Test…
Minh Tran
  • 733
  • 1
  • 7
  • 19
23
votes
7 answers

Integer.parseInt number format exception?

I feel like I must be missing something simple, but I am getting a NumberFormatException on the following code: System.out.println(Integer.parseInt("howareyou",35)) Ideone It can convert the String yellow from base 35, I don't understand why I…
Danny
  • 6,838
  • 8
  • 40
  • 65
16
votes
10 answers

Radix Sort for Negative Integers

I am trying to implement radix sort for integers, including negative integers. For non-negative ints, I was planning to create a queue of 10 queues correspondingly for the digits 0-9 and implement the LSD algorithm. But I was kind of confused with…
gtkesh
  • 391
  • 1
  • 2
  • 10
15
votes
6 answers

Trie implementation

I am attempting to implement a very simple Trie in Java that supports 3 operations. I'd like it to have an insert method, a has method (ie is a certain word in the trie), and a toString method to return the trie in string form. I believe I have…
dc.
  • 1,419
  • 2
  • 16
  • 29
12
votes
2 answers

Java numbers with radix > Character.MAX_RADIX

I have a five-character String and I want to use those five characters as an ASCII-encoded (printable) number. The simplest way to achieve this is to use Long.toString(number, Character.MAX_RADIX); This will give me numbers from "0" to "zzzzz".…
Lukas Eder
  • 181,694
  • 112
  • 597
  • 1,319
11
votes
2 answers

Implementing a Patricia Trie for use as a dictionary

I'm attempting to implement a Patricia Trie with the methods addWord(), isWord(), and isPrefix() as a means to store a large dictionary of words for quick retrieval (including prefix search). I've read up on the concepts but they just aren't…
Regis Frey
  • 887
  • 1
  • 11
  • 21
9
votes
1 answer

Exception was thrown: FormatException: Invalid radix-10 number

I get this error when try to get an integer from TextFormFeild. I have used this widget many times but I did not get this error anytime. Does anybody know what it exactly means? It will be a great help. The following is just a part of entire (1084…
yash javeri
  • 347
  • 1
  • 4
  • 15
8
votes
2 answers

FormatException: Invalid radix-10 number

I'm trying to receive a get request using Flutter and HttpClient. This is complete code in what I'm trying to accomplish. getSuggest() async { try { var httpClient = new HttpClient(); var uri = new Uri.http( …
DanMossa
  • 825
  • 2
  • 14
  • 33
8
votes
2 answers

Can you formulate a monoid or semigroup for the radix sort?

This is the pseudocode for the radix sort: Pseudocode for Radix Sort: Radix-Sort(A, d) // Each key in A[1..n] is a d-digit integer. (Digits are // numbered 1 to d from right to left.) 1. for i = 1 to d do Use a stable sorting algorithm to sort A on…
hawkeye
  • 31,052
  • 27
  • 133
  • 271
7
votes
1 answer

inet_aton normalization of a IPv4 address

doesn't inet_aton suppose to normalize the dot version of the internet address? why do I get different output values for the example below? int main(){ char USER_IP[16] = "192.168.002.025"; char USER_IP2[16] = "192.168.2.25"; struct…
sven
  • 1,031
  • 6
  • 18
  • 41
1
2 3
11 12