is this even right?

This commit is contained in:
brent s. 2021-05-23 04:49:08 -04:00
parent a31d50359a
commit 4eb554aa38
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
3 changed files with 53 additions and 8 deletions

1
dh/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
moduli.c

View File

@ -30,11 +30,3 @@ const (


var ( var (
) )

// Bit* functions operate on 32-bit words
func BitClear(a []uint32, n uint32) (i uint32) {

i = a[n >> ShiftWord] &= ~(uint32(1) << (n & 31))

return
}

52
dh/func_utils.go Normal file
View File

@ -0,0 +1,52 @@
package dh

func bitShiftWord(a []uint32, n uint32) (i uint32) {

i = a[n>>ShiftWord]

return
}

// Bit* functions operate on 32-bit words
func BitClear(a []uint32, n uint32) (i uint32) {

/*
#define BIT_CLEAR(a,n) ((a)[(n)>>SHIFT_WORD] &= ~(1L << ((n) & 31)))
*/

var x uint32 = bitShiftWord(a, n)
var y uint32 = uint32(1) << (n & 31)
var z uint32 = ^y

i = x & z

return
}

func BitSet(a []uint32, n uint32) (i uint32) {

/*
#define BIT_SET(a,n) ((a)[(n)>>SHIFT_WORD] |= (1L << ((n) & 31)))
*/

var x uint32 = bitShiftWord(a, n)
var y uint32 = uint32(1) << (n & 31)

i = x | y

return
}

func BitTest(a []uint32, n uint32) (i uint32) {

/*
#define BIT_TEST(a,n) ((a)[(n)>>SHIFT_WORD] & (1L << ((n) & 31)))
*/

var x uint32 = bitShiftWord(a, n)
var y uint32 = uint32(1) << (n & 31)

i = x & y

return
}