Results 1 to 4 of 4

Thread: data assignment

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    UK
    Posts
    18

    Talking data assignment

    I am using an old version of MS C++ compiler 1.5 and want to be able to assign a binary value directly to a variable. I know how to assign hex, decimal, long and octal values but not binary. For example:

    unsigned char MyVal = 5;

    needs to be

    unsigned char MyVal = 00000101;

    Thanks for any help.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    any reason for this? c++ doesn't allow that but you can make up some templates that does it at compile time or use atoi at runtime but thats just a waste of time both compile design and runtime if you ask me. if its just for aestetic reasons forget about it and write in hex and get on with it, or choose another language.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2002
    Location
    UK
    Posts
    18
    I am porting over a driver for a graphics LCD display that was originally written in assembler and already have the 256 char bitmapped character set that i want to use. This saves me having to go through and convert every character manually (8x8 font, lots of conversion). If there is no way to do this i will have to write something to read the file and automate the conversion. Thanks.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    use atoi with base 2
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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