Lolling at programmers, how many ways are there to create a bitmask ? ;) :)

R

Rudy Velthuis

James said:
I'm not going to try and defend him but having seen his posts for some
time I don't think he's trolling.

He usually thinks he is extremely clever and wants to show it. <g>

I suspect some mental problems too.


--
Rudy Velthuis http://rvelthuis.de

"It may be that our role on this planet is not to worship God,
but to create him."
-- Arthur C. Clarke
 
R

Rudy Velthuis

James said:
The rest is mainly
communication style.

Then you don't really know his posting history on Usenet. He doesn't
listen to advice, he doesn't read up on any basics, he is generally
completely clueless. He just picks up some crumbs of information here
and there, and he simply thinks he can find out everything else by
experimenting and by using his immensely (in his view) great mind.
 
R

Rudy Velthuis

Andy said:
Many instruction sets do not handle constants greater than some size
well. Above you have a 16 bit constant.

Even though x86 handles most constants in the instruction set, larger
constants cost instruction bytes.



This is what I would usually recommend. Although, on some machines,
shifts of any form are slow.

Any decent compiler will turn "(1 shl BitCount) - 1" into a constant
(immediate value for the assembler freaks), if BitCount is constant.
And if it isn't, I still don't see a better way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top