From: io_x on 26 May 2010 13:19 "Chad" <cdalten(a)gmail.com> ha scritto nel messaggio news:8853a458-f688-461d-9863-424fb40bc30b(a)g39g2000pri.googlegroups.com... On May 25, 6:54 am, "Skybuck Flying" <IntoTheFut...(a)hotmail.com> wrote: > My advice will be: > > Create test programs which test full ranges, and have independent code which > test for correct input, correct memory and correct output value's... bit by > bit if necessary. > > Such test programs will catch all cases. > > I already created such a test program to test my WriteBitfield routines... > and the test program proved to be highly successfull and usefull ! =D > <off topic> I can't tell if you are holding a conversation with yourself or if the computers at my job are just doing some kind of wierd filtering that isn't allowing me to see who you are talking to. </off topic> any answer here should be for the all NG, so for who write and all the remain people that read. so even if i answer to myself i speak to all, me too :)
From: MitchAlsup on 26 May 2010 14:02 On May 25, 10:51 am, Andy 'Krazy' Glew <ag-n...(a)patten-glew.net> wrote: > > 4. (MitchAlsup) Mask := not word((not 0) shl BitCount); // not((not 0 = > > 1111111) shl 3 = 1111000) = 0000111 > > Trades off constant size for instruction count. Not in C Mitch
From: pete on 26 May 2010 18:29 Skybuck Flying wrote: > > Ok people, > > I keep coming across different ways in source codes for creating a bit mask > for a certain ammount of bits and it's kinda funnieing me out ! =D > > Therefore to have some fun, it's time to create a thread dedicated to > creating bitmasks... how many ways are there ? > > So far I have come across these methods: > > 1. (My own way:) Mask := not word(65535 shl BitCount); // not 1111000 = > 0000111 > > 2. Mask := (1 shl BitCount)-1; // 10000-1 = 09999 = 01111 ;) :) > > 3. Mask := ($FFFF shl BitCount) xor $FFFF; // 1111000 xor 1111111 = 0000111 size_t odd_mask = size ^ size - 1; and size_t bytes = nmemb * size; implies that if ((bytes & odd_mask) != 0) then nmemb must be odd. -- pete
From: Skybuck Flying on 26 May 2010 21:32 Question is what happens when "shl 32" is done. According to the intel manual the result would be undefined ?!? Does that mean the result could be garbage ??? Bye, Skybuck.
From: Seebs on 26 May 2010 21:25
On 2010-05-27, Skybuck Flying <IntoTheFuture(a)hotmail.com> wrote: > Question is what happens when "shl 32" is done. *sigh* > According to the intel manual the result would be undefined ?!? Yes. > Does that mean the result could be garbage ??? Tell you what. Try posting this coherently with a reasonable amount of punctuation, and I'll totally point out that the word "undefined" is completely unambiguous, since apparently this is not obvious enough. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! |