Thread: Code convertor

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Red face Code convertor


    [C language,win7]
    Please,
    Can anyone please give me a short program for code converting
    (Decimal code to binary code) :confused:

    Comments on this post

    • ptr2void disagrees : No, do your own damn homework, Venkatesh!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,841
    Rep Power
    480
    Clearly, you need to post an attempt of some sort and explain the trouble you're having.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    Also, you need a precise specification of what "converting (Decimal code to binary code)" is supposed to mean.

    All values are stored within the computer as binary code. Internally within a computer, there is no such thing as "decimal code", though there can be and are a number of ways to binarily encode decimal (eg, binary-coded decimal (BCD), packed decimal). Is that the "decimal code" that you need to convert to straight binary? Well then, you need to specify the exact format of that "decimal code"!

    Now, values can be expressed in character strings, such as in "1234". Is that what you mean by "decimal code"? That is a very serious question that you need to ask and to answer for yourself and for anybody working on this with you. Now, if that is what you mean by "decimal code", then converting that to actual binary code is an extremely common task for where there is a standard library function, scanf().

    Expressing a value in a character string also works for output strings as well as for input strings. printf allows you to output a value in decimal, hexadecimal, and octal, but not in binary. So if you want to convert an internal value to a character string that expresses that value in binary, then you need to specify that.

    If you have no idea what precisely you need to do, how could you ever write a program to do it?

IMN logo majestic logo threadwatch logo seochat tools logo