|
-
Jul 31st, 2001, 04:10 PM
#1
Bitwise operations
Ho can I check if the most (or least) significant bit of a value is set?
-
Jul 31st, 2001, 05:56 PM
#2
transcendental analytic
low bit
x & 1
hi bit
x & y
or to return a value 1 or 0
x >> z
where
z=(sizeof(x)-1)*8
and
y is 2^z
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.
-
Aug 1st, 2001, 02:40 PM
#3
thanks
That will do.
Thanks kedaman.
-
Aug 1st, 2001, 04:20 PM
#4
¿¿??
I took a closer look at it and came up with this
z=sizeof(x)*8 - 1
rather than what you wrote.
I'll assume this is what you meant.
thanks anyway; I got the idea.
-
Aug 1st, 2001, 04:47 PM
#5
transcendental analytic
yeah that's it 
x was of course meant to be the type of x, but since you got the idea, everythign is the compiler may or may not optimize it though, so you'd better evaluate z
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|