base-conversion

Converting an integer to a hexadecimal string in Ruby

Is there a built in way to convert an integer in Ruby into its hexadecimal equivalent. The opposite of "0A".to_i(16) =>10 or "0A".hex =>10 I know how to roll my own, but it's probably more efficient to use a built in ruby function ...

Base conversion of arbitrary sized numbers (PHP)

I have a long "binary string" like the output of PHPs pack funtion. How can I convert this value to base62 (0-9a-zA-Z)? The built in maths functions overflow with such long inputs, and BCmath doesn't have a base_convert function, or anything that specific. I would also need a matching "pack base62" function. ...

How can I output a number as a string of bits in C#?

In C#, how can I output a number as binary to the console? For example, if I have a uint with the value of 20, how can I print to the console: 00010100 (which is 20 in binary)? ...

Print large base 256 array in base 10 in c

I have an array of unsigned chars in c I am trying to print in base 10, and I am stuck. I think this will be better explained in code, so, given: unsigned char n[3]; char[0] = 1; char[1] = 2; char[2] = 3; I would like to print 197121. This is trivial with small base 256 arrays. One can simply 1 * 256 ^ 0 + 2 * 256 ^ 1 + 3 * 256 ^ 2. ...

ICertRequest2::Submit CSR data Compatability ASCII to BSTR

Hello Experts, I have my certrequest as a PEM base64 data. See data below. 1) My understanding is that this is an ASCII data type and not in UNICODE format. Please clarify. -----BEGIN NEW CERTIFICATE REQUEST----- MIIBTjCBuAIBADARMQ8wDQYDVQQDEwZ3dTAwMzEwgZ0wDQYJKoZIhvcNAQEBBQAD gYsAMIGHAoGBAKP48eljetv3fVicT6g6hKjmLpsySJaZ/NnepEJEqtQQNbw...

Converting non-decimal numbers to another non-decimal

Not that it's a lot of work, but the only way I know to convert a non-decimal to another non-decimal is by converting the number to decimal first, then take a second step to convert it to a new base. For example, to convert 456 (in base 7) to 567 (in base 8), I would calculate the decimal value of 456, then convert that value into base 8...

Convert hex to decimal in make script?

A make script is attempting to set a variable as follows: VER_DEC=$( perl -e "print hex(\"$(VER_HEX)\");" ) where VER_HEX happens to have a value of 0a. Perl seems to think that VER_HEX is zero, implying that the variable isn't set (but it is, according to a debug echo in the makefile). Does make have a simpler way to convert bases?...

converting from base 10 to base 31 (working only with select characters)

I'd like to convert base 10 numbers to base 31 I would like to use only these characters: 23456789abcdefghjkmnpqrstuvwxyz As you can see, 5 characters are excluded (i don't need these): 1 0 o l i The function I have now is below but of course it doesn't work. When 2 is input it outputs 4. The output for tenTo31(2) should be 2 functio...

PHP - How to base_convert() up to base 62

I need a base_convert() function that works from base 2 up to base 62 but I'm missing the math I need to use, I know that due to the limitations of PHP I need to make use of bcmath, which is fine. Functions like these convert a number to and from base 10 to another base up to 62, but I want to implement the same functionality of base_co...

Getting a hexadecimal number into a program via the command line

I can do this: int main(int argc, char** argv) { unsigned char cTest = 0xff; return 0; } But what's the right way to get a hexadecimal number into the program via the command line? unsigned char cTest = argv[1]; doesn't do the trick. That produces a initialization makes integer from pointer without a cast warning. ...

How can I convert a number in a string to any base in assembly?

How can I convert a number contained in a string from any base to any other base? Bases can be anything i.e.: 2, 16, 10, 4, 8, 9. I'm expecting the user to enter the base number. The user will enter the output base (the base to be converted to). The user will enter the number he wants to convert. Pre thoughts: I will save the input b...

algorithm to convert a number in an unknown base to the equivalent base 10 number

Given an integer, write a program that converts the given number to a number (in base 10). Hint - The given number could be in any base, but the base is unknown. ...

PL/SQL base conversion without functions

Is there any way to convert decimal to binary, or binary to decimal, in Oracle 10g without having to first define a function? I have limited database access (SELECT only) and all the solutions for this I've found online seem to involve CREATE FUNCTION, which does not work for me. ...