Artifact
09721112db72b2a90f12cadb5816c48182c57b54:
Attachment "bignum-bitops2.diff" to
ticket [1093414fff]
added by
aakhter
2004-12-31 02:20:52.
? bitor.tcl
Index: bignum.man
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/math/bignum.man,v
retrieving revision 1.2
diff -r1.2 bignum.man
179a180,191
> [call [cmd ::math::bignum::bitand] [arg a] [arg b]]
> Return the result of doing a bitwise AND operation on a
> and b.
>
> [call [cmd ::math::bignum::bitor] [arg a] [arg b]]
> Return the result of doing a bitwise OR operation on a
> and b.
>
> [call [cmd ::math::bignum::bitxor] [arg a] [arg b]]
> Return the result of doing a bitwise XOR operation on a
> and b.
>
Index: bignum.tcl
===================================================================
RCS file: /cvsroot/tcllib/tcllib/modules/math/bignum.tcl,v
retrieving revision 1.2
diff -r1.2 bignum.tcl
486a487,522
> # does bitwise and between a and b
> proc ::math::bignum::bitand {a b} {
> while {[llength $a] < [llength $b]} {lappend a 0}
> while {[llength $b] < [llength $a]} {lappend b 0}
> set r [::math::bignum::zero [expr {[llength $a]-1}]]
> for {set i 2} {$i < [llength $a]} {incr i} {
> set or [expr {[lindex $a $i] & [lindex $b $i]}]
> lset r $i $or
> }
> ::math::bignum::normalize r
> }
>
> # does bitwise XOR between a and b
> proc ::math::bignum::bitxor {a b} {
> while {[llength $a] < [llength $b]} {lappend a 0}
> while {[llength $b] < [llength $a]} {lappend b 0}
> set r [::math::bignum::zero [expr {[llength $a]-1}]]
> for {set i 2} {$i < [llength $a]} {incr i} {
> set or [expr {[lindex $a $i] ^ [lindex $b $i]}]
> lset r $i $or
> }
> ::math::bignum::normalize r
> }
>
> # does bitwise or between a and b
> proc ::math::bignum::bitor {a b} {
> while {[llength $a] < [llength $b]} {lappend a 0}
> while {[llength $b] < [llength $a]} {lappend b 0}
> set r [::math::bignum::zero [expr {[llength $a]-1}]]
> for {set i 2} {$i < [llength $a]} {incr i} {
> set or [expr {[lindex $a $i] | [lindex $b $i]}]
> lset r $i $or
> }
> ::math::bignum::normalize r
> }
>