Three components - Base, value, sign. ie. Base.....Decimal (10) (our every day numbering system) Value....The value of the number (ie 3,5,9) Sign......Positive or negative
25 base 10
9 (in decimal). In any other base, it is (base-1)
a decimal
If that's binary, it's 55 base 10.
54 base 10
It is the value of a number which is expressed in base 16 rather than the "normal" decimal, or base 10, form.
Three components - Base, value, sign. ie. Base.....Decimal (10) (our every day numbering system) Value....The value of the number (ie 3,5,9) Sign......Positive or negative
25 base 10
9 (in decimal). In any other base, it is (base-1)
The base of a wave is the lowest point of the wave where it meets the horizontal axis. It represents the starting point of the wave's oscillation.
1001 0111 base 2
a decimal
If that's binary, it's 55 base 10.
The algorithm to convert from decimal to any other base is the same regardless of the base. Divide the decimal value by the base and take the remainder. This is the least significant digit. Repeatedly divide the result of the previous division by the base to get the next least significant digit, and so on until the result is zero. Converting from any non-decimal base to any other base is slightly more difficult because C++ only recognises decimal and hexadecimal values (which are obviously converted to and from binary for our convenience). However since we must use character arrays to represent all other bases, the simplest solution is to convert those strings to decimal and then convert to the required base using the previously mentioned algorithm. The following program provides 2 functions which allow relatively simple conversion from decimal to any base from 2 to 62, and back to decimal again. Note that Dec2Base() returns a null-terminated character array of the exact size required which can then be passed to Bin2Dec() to produce the original decimal value. Between these two functions you can convert from any base to any other base in the range 2 to 62. The test program output is shown at the bottom of the example. #include <iostream> // Convert to any base from 2 to 62 inclusive. const char MAXBASE = 62; // Note: Higher bases are possible, but we only have 61 symbols // to play with (0-9, A-Z and a-z). Bases 11 through 36 are not // case-sensitive (although we will use upper-case here), while // higher bases use upper-case for the digits 10 through 35 and // lower-case for the digits 36 through 61. // Note that negative values use the '-' symbol, even in binary. // Computers do not. Computers represent the value -1 as being // 10000000 in 8-bit binary (the most significant bit represents // the sign). The value -0 does not exist hence the least // significant bit is zero, not 1 as might be expected. However, // we humans can use the '-' symbol to differentiate positive // and negative decimal values, so there's no reason not to // follow this convention with all bases. // Convert the given signed decimal value to the given base and // return the buffer pointed to by the non-zero pointer to pointer. char * Dec2Base( int dec, char base, char ** buffer ) { // The pointer-to-pointer MUST be non-zero. if( !buffer ) return( 0 ); // Point to the actual buffer (may be NULL). char * p = *buffer; // Check validity. if( dec && base > 1 && base <= MAXBASE ) { // Some variables. unsigned int size = 1; int rem = dec; // Is the value signed? if( rem < 0 ) { // Increase the initial size to cater for sign. ++size; // Convert the value to a positive value. rem = dec *= -1; } // Release the buffer, if required. if( p ) free( p ); // Calculate the required buffer size. while( rem /= base ) ++size; // Allocate a null-terminated buffer and zero it. p = ( char * ) malloc( ++size ); memset( p, 0, size-- ); // Update the output parameter. if( *buffer != p ) *buffer = p; // Point to the null terminator. p += size; // Start with the least-significant first. while( dec ) { // Step back to the correct character. --p; // Determine the digit value (remainder of division). rem = dec % base; // Determine the symbol. if( rem < 10 ) *p = '0' + rem; else if( rem < 36 ) *p = 'A' + rem - 10; else *p = 'a' + rem - 36; // Prepare for next digit. dec /= base; } // Signed value? if( p != *buffer ) { --p; *p = '-'; } } // Return the buffer. return( *buffer = p ); } int Base2Dec( char * buffer, char base ) { // Initialise the return value. int decimal = 0; // The buffer MUST BE null-terminated! unsigned int size = strlen( buffer ); // Point to the null-terminator. char * p = buffer; p += size; // The least-significant column is always the units, // with position value 1. unsigned int posval = 1; // Repeat until we reach the most-significant digit. while( p != buffer ) { // Step back to the digit. --p; // Store the the digit's value unsigned int val = *p; // Is it a sign? if( val == '-' ) // Adjust the result. decimal *= -1; // Not a sign, must be a digit. else { // Convert the digit to a decimal value. if( val > 'a' ) { val -= 'a'; val += 36; } else if( val > 'A' ) { val -= 'A'; val += 10; } else val -= '0'; // Multiply by the position value. val *= posval; // Increment the result. decimal += val; // Calculate the next position value. posval *= base; } } // Success. return( decimal ); } // Test program. int main() { // The test value: int decimal = -54321; // Initialise a pointer. char * buffer = 0; // Compute all bases from 2 through MAXBASE. char base = 1; while( ++base <= MAXBASE ) printf( "%d in decimal is %s in base %u\n", decimal, Dec2Base( decimal, base, &buffer ), base ); // Convert from MAXBASE back to decimal: printf( "%s in base %d is %d in decimal\n", buffer, MAXBASE, Base2Dec( buffer, MAXBASE )); // Don't forget to release the buffer! if( buffer ) free( buffer ); // Success! return( 0 ); } Output: -54321 in decimal is -1101010000110001 in base 2 -54321 in decimal is -2202111220 in base 3 -54321 in decimal is -31100301 in base 4 -54321 in decimal is -3214241 in base 5 -54321 in decimal is -1055253 in base 6 -54321 in decimal is -314241 in base 7 -54321 in decimal is -152061 in base 8 -54321 in decimal is -82456 in base 9 -54321 in decimal is -54321 in base 10 -54321 in decimal is -378A3 in base 11 -54321 in decimal is -27529 in base 12 -54321 in decimal is -1B957 in base 13 -54321 in decimal is -15B21 in base 14 -54321 in decimal is -11166 in base 15 -54321 in decimal is -D431 in base 16 -54321 in decimal is -B0G6 in base 17 -54321 in decimal is -95BF in base 18 -54321 in decimal is -7H90 in base 19 -54321 in decimal is -6FG1 in base 20 -54321 in decimal is -5I3F in base 21 -54321 in decimal is -5253 in base 22 -54321 in decimal is -4AFI in base 23 -54321 in decimal is -3M79 in base 24 -54321 in decimal is -3BML in base 25 -54321 in decimal is -3297 in base 26 -54321 in decimal is -2KDO in base 27 -54321 in decimal is -2D81 in base 28 -54321 in decimal is -26H4 in base 29 -54321 in decimal is -20AL in base 30 -54321 in decimal is -1PG9 in base 31 -54321 in decimal is -1L1H in base 32 -54321 in decimal is -1GT3 in base 33 -54321 in decimal is -1CXN in base 34 -54321 in decimal is -19C1 in base 35 -54321 in decimal is -15WX in base 36 -54321 in decimal is -12P5 in base 37 -54321 in decimal is -bNJ in base 38 -54321 in decimal is -ZRX in base 39 -54321 in decimal is -Xc1 in base 40 -54321 in decimal is -WCb in base 41 -54321 in decimal is -UXF in base 42 -54321 in decimal is -TGC in base 43 -54321 in decimal is -S2P in base 44 -54321 in decimal is -Qb6 in base 45 -54321 in decimal is -PUf in base 46 -54321 in decimal is -ORa in base 47 -54321 in decimal is -NRX in base 48 -54321 in decimal is -MUT in base 49 -54321 in decimal is -LaL in base 50 -54321 in decimal is -Kj6 in base 51 -54321 in decimal is -K4X in base 52 -54321 in decimal is -JHn in base 53 -54321 in decimal is -IXp in base 54 -54321 in decimal is -Hqa in base 55 -54321 in decimal is -HI1 in base 56 -54321 in decimal is -Gf0 in base 57 -54321 in decimal is -G8X in base 58 -54321 in decimal is -FZf in base 59 -54321 in decimal is -F5L in base 60 -54321 in decimal is -EaV in base 61 -54321 in decimal is -E89 in base 62 -E89 in base 62 is -54321 in decimal
decimal
110 in decimal = 1101110 in binary (base 2). Interesting that the decimal value 110 is read in there twice! If you actuall meant the question "What is 110 in binary equivalent to in decimal?" then the answer is 4+2=6.