CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2014
    Posts
    1

    Help Convert Signed Decimal Number to Binary and Vice Versa

    Greetings, I understand how to convert positive decimals to binary and vice versa, but I am not quite sure how to go about factoring in negative numbers with their binary equivalents. It must be 8 bits (therefore, the decimal outputs must range from -128 to 127). Please help!
    PS: I am not allowed to use toBinaryString for reasons unstated.

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,877

    Re: Help Convert Signed Decimal Number to Binary and Vice Versa

    how to convert positive decimals to binary
    You can use an assignment statement to copy a value in an int variable to a byte variable by casting it.
    Or are you talking about converting a String of decimal digit (0-9) characters to a String of binary digit (0-1) characters?
    Norm

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured