Prev: 100% without investment online part time jobs..(adsense,datawork,neobux..more jobs)
Next: clock format causes infinite loop? with its use of "dict exists"
From: mallikarjunarao on 6 Aug 2010 02:12 On Aug 5, 10:27 pm, Bezoar <cwjo...(a)gmail.com> wrote: > On Aug 5, 6:44 am, mallikarjunarao <malli....(a)gmail.com> wrote: > > > hi , > > how to identify odd 1's in a binary number my binary numbers is > > 110010001010101111110110 > > 11010101010101111110110 > > 11101101010101100011011 > > 11111100110101010111101 > > Are you saying you want to identify the binary numbers where there is > a 1 in and odd position(e.g 001, 1 is in position 3 (if count starts > at 1 ) ), the resuting number is odd, the count of ones showing up in > the binary number is odd? > for the second just check to see if last digit is 1 > > proc isOddNum { num } { > return [expr ([string index $num end ] == "1") ? 1 : 0 ] > > } > > for the latter : > > set num 11111100110101010111101 > proc isCountOfOnesOdd { num } { > # compress 0's then apply modulus 2 to resulting string > return [expr {[string length [string match {"0" ""} $num ] ] % > 2 }]; > > } > > i didn't want count i need only the 1 bits in odd position
From: Andreas Leitgeb on 6 Aug 2010 07:52
mallikarjunarao <malli.kv2(a)gmail.com> wrote: > i didn't want count i need only the 1 bits in odd position I did post a solution for that. |