# Tag Info

Accepted

### Hexadecimal bytes as variable converted to binary bits

You cannot use the notation 16^^ with variable arguments, since it does not get "evaluated" like normal functions, but rather it is just a way of writing ...
• 3,505
Accepted

### DigitCount[], but in negative bases

Background mathworld.wolfram.com contains entries for Negabinary, Negadecimal and Base, including Wolfram language code examples Base $(-2)$ Negabinary ...
• 36.5k
Accepted

### Integer to Alpha Representation

I think you can use IntegerDigits directly if you add an offset, and then use the 3rd argument of IntegerDigits to only return ...
• 131k
Accepted

### convert the BaseForm of 2 (binary data) to an array

IntegerDigits is for this: PadLeft[#, 3] & /@ Table[IntegerDigits[i, 2], {i, 0, 4}] {{0, 0, 0}, {0, 0, 1}, {0, 1, 0}, {...
• 23.9k

### Using FromDigits to convert number strings to numbers

It looks to me that when you copied you copied the plain text form not the input form of the list of strings representing your hexadecimal numbers. Normally, copying form output cells gives the input ...
• 108k
Accepted

### Why ImportByteArray when generate image from bytes

There are a couple of issues here. First, the full text of Image::imgarray sheds light on one issue: ...
• 34k

### Integer to Alpha Representation

A memoized recursive approach seems faster: ...
• 67.2k

### How can I convert the output of IntegerString[n, "Base64"] back into base 10?

Here's something you could try. First, build the mapping to "decode" a Base64 encoding as if it represented a digit sequence: ...
• 28k

### Extracting powers of a sum

Use IntegerDigits instead of BaseForm. (* some prior computations... *) n = 3; kl = {1, 2, 3}; value = Sum[n^k, {k, kl}]; Now, assuming that you know what n was ...
• 28k

### Hexadecimal bytes as variable converted to binary bits

FromDigits is fast but it does not catch invalid inputs. IntegerDigits[FromDigits["C12BZ", 16], 2] {1, 1, 0, 0, 0, 0,...
• 8,741

### Using FromDigits to convert number strings to numbers

Welcome to the world of coding! Objects like numbers and words have different types in programming languages like Mathematica. It's important to pay attention to the types of the objects you create. ...
Accepted

### Problem defining a function that takes a binary input to its decimal form

The code binarytodecimal[b_String] := NumberForm[ToExpression["2^^"<>b], 20]; does what you want. For example ...
• 4,897

### DigitCount[], but in negative bases

Here is my solution which uses a loop format mimicking the solutions on Wikipedia ...

### Speed up counting of digits in binary number

Please investigate how this technique fares in your application. Let's say: SeedRandom[1]; binSequence = RandomInteger[{0, 1}, 20] {1, 1, 0, 1, 0, 0, 0, 1, 0, 1, ...
• 53.2k

### Find a number's digits in an arbitrary base

Alternatively to IntegerDigits you can "write a program" yourself. Something like this will work for positive numbers: ...
• 6,428

### Function for converting to base b, taking derivative with respect to b and evaluating at b

For your particular problem: D[IntegerDigits[37, 5] {b^2, b, 1}, b] /. {b -> 5} // Total 12 In general you can create a function: ...
• 69k
Accepted

### How do I check if the base-$b$ representation of my number contains the same digits?

As @HenrikSchumacher mentioned, IntegerDigits works: ...
• 9,783
Accepted

### How can I convert an integer to a binary list?

Try IntegerDigits: IntegerDigits[6, 2] {1, 1, 0}
• 395k

### Integer to Alpha Representation

Mod and Quotient support offsets, allowing: ...
• 271k
Accepted

### Function for converting to base b, taking derivative with respect to b and evaluating at b

f[n_, b_] := Module[{dig}, dig = IntegerDigits[n, b]; D[dig.Table[x^i, {i, Length@dig - 1, 0, -1}], x] /. x -> b ] Maybe a different example for ...
• 23.9k

### Function for converting to base b, taking derivative with respect to b and evaluating at b

db[n_Integer, b_Integer] := FromDigits[(# Range[Length@#, 1, -1]) &@ Most@IntegerDigits[n, b], b] or ...
• 38.9k
Accepted

### How to preserve real number's precision

This may seem counter-intuitive, but what works is to rationalize the number first, Rationalize[523.502] (* 261751/500 *) This allows us to take advantage of the ...
• 68.4k

### How to calculate the rightmost 1 and the leftmost 1 in the binary representation of a large number x?

You can use IntegerLength and IntegerExponent: SeedRandom[77]; x = RandomInteger[{1, 2^64}] ...
• 395k

### Speed up counting of digits in binary number

The post linked by MarcoB contains a link to this Wikipedia page which is very illuminating: https://en.wikipedia.org/wiki/Hamming_weight There I found also the very useful remark that a population ...

### Convert List of integers to Hex

Define a function to convert a number to a 64-bit hex string while respecting two's complement representation: (thanks to Michael for simplifying!) ...
• 47.4k
Accepted

### Conversion to expression in base 17 with particular needs

Perhaps you can do: ...
• 131k

### Base 12 input and output without ^^ or BaseForm

Updated to work with strings instead of boxes One idea is to create a "Duodecimal" style that automatically interprets strings as base 12 integers, and outputs the result in ...
• 131k

### Splitting a binary number into smaller parts and converting each smaller part back to decimal

string = "1111 01001000100110001101010 111111 0000101101110110011100101"; FromDigits[#, 2] & /@ StringSplit[string] {15, 2378858, 63, 1502437} Update: To ...
• 395k