Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Visual Basic (https://www.askmehelpdesk.com/forumdisplay.php?f=469)
-   -   VB codes for creating scientific calculator (https://www.askmehelpdesk.com/showthread.php?t=344640)

  • Apr 22, 2009, 04:45 AM
    Samjar
    VB codes for creating scientific calculator
    If possible I need help on codes for converting numbers such as Binary to octal,Binary to Decimal number system, thnks in advance
  • Apr 28, 2009, 06:25 AM
    Perito

    It would be simpler if you had a specific problem. But, I'll try to answer without too much comment.

    To convert a number in binary to decimal, the usual route is to break it down into its individual numerals. For example, the binary number, "1011", would be broken down into four digits, 1-0-1-1. There are a number of ways to do this. Starting with the numeral on the far right, you multiply the digit by 2^n where n is the bit number. Remember that "n" is 0 for the rightmost digit and 2^0 = 1. The result is, therefore:

    1 * 2^0 = 1
    1 * 2^1 = 2
    0 * 2^2 = 0
    1 * 2^3 = 8
    Add up the numbers 8+0+2+1 = 11 (decimal).

    You can do this for other bases except instead of using 2 to the power, you use 8 to the power (for octal) or 16 to the power (for hexadecimal), etc.

    To convert from decimal to any number base, simply divide by the base repeatedly. The remainders are concatenated in a string. As an example, I'll convert 238 (decimal) to octal (divide by 8) and hexadecimal (divide by 16):







    The remainders, in reverse order, are 356. Therefore, 238 (decimal) = 356 (octal).

    in Hexadecimal, we typically use the following set of numerals: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

    (E is the numeral corresponding to 14)



    So, 238 (decimal) = EE (hexadecimal). Note that the divisions are done using base 10 arithmetic. Only use the hexadecimal set of numerals when evaluating the remainder.

    The above are algorithms. If you need actual VB code, I can probably generate it.
  • Nov 29, 2011, 10:45 PM
    sadaha
    Can you generate it sir to vb6
  • Feb 7, 2012, 07:57 AM
    hasiii
    Give me a sorce code u ****erzzzzzzzzzzzzzz

  • All times are GMT -7. The time now is 08:55 PM.