Search Options

Results per page
Sort
Preferred Languages
Advance

Results 31 - 40 of 150 for bitLen (0.12 sec)

  1. src/math/big/ratconv_test.go

    			// float64 become -0, but Rat obviously cannot
    			// preserve the sign from SetString("-0").
    			switch {
    			case math.Float32bits(e) == math.Float32bits(f):
    				// Ok: bitwise equal.
    			case f == 0 && r.Num().BitLen() == 0:
    				// Ok: Rat(0) is equivalent to both +/- float64(0).
    			default:
    				t.Errorf("strconv.ParseFloat(%q) = %g (%b), want %g (%b); delta = %g", input, e, e, f, f, f-e)
    			}
    		}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Nov 15 22:16:34 UTC 2023
    - 19.3K bytes
    - Viewed (0)
  2. src/go/constant/value.go

    		return makeRat(x)
    	case *big.Float:
    		return makeFloat(x)
    	default:
    		return unknownVal{}
    	}
    }
    
    // BitLen returns the number of bits required to represent
    // the absolute value x in binary representation; x must be an [Int] or an [Unknown].
    // If x is [Unknown], the result is 0.
    func BitLen(x Value) int {
    	switch x := x.(type) {
    	case int64Val:
    		u := uint64(x)
    		if x < 0 {
    			u = uint64(-x)
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Oct 19 12:02:03 UTC 2023
    - 34K bytes
    - Viewed (0)
  3. src/net/ip.go

    		return nil, nil, &ParseError{Type: "CIDR address", Text: s}
    	}
    
    	n, i, ok := dtoi(mask)
    	if !ok || i != len(mask) || n < 0 || n > ipAddr.BitLen() {
    		return nil, nil, &ParseError{Type: "CIDR address", Text: s}
    	}
    	m := CIDRMask(n, ipAddr.BitLen())
    	addr16 := ipAddr.As16()
    	return IP(addr16[:]), &IPNet{IP: IP(addr16[:]).Mask(m), Mask: m}, nil
    }
    
    func copyIP(x IP) IP {
    	y := make(IP, len(x))
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sat May 18 03:13:26 UTC 2024
    - 13.9K bytes
    - Viewed (0)
  4. src/math/big/nat.go

    	}
    	return z
    }
    
    func putNat(x *nat) {
    	natPool.Put(x)
    }
    
    var natPool sync.Pool
    
    // bitLen returns the length of x in bits.
    // Unlike most methods, it works even if x is not normalized.
    func (x nat) bitLen() int {
    	// This function is used in cryptographic operations. It must not leak
    	// anything but the Int's sign and bit size through side-channels. Any
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon May 13 21:31:58 UTC 2024
    - 31.7K bytes
    - Viewed (0)
  5. src/cmd/compile/internal/ssa/magic.go

    func umagic(n uint, c int64) umagicData {
    	// Convert from ConstX auxint values to the real uint64 constant they represent.
    	d := uint64(c) << (64 - n) >> (64 - n)
    
    	C := new(big.Int).SetUint64(d)
    	s := C.BitLen()
    	M := big.NewInt(1)
    	M.Lsh(M, n+uint(s))     // 2^(n+s)
    	M.Add(M, C)             // 2^(n+s)+c
    	M.Sub(M, big.NewInt(1)) // 2^(n+s)+c-1
    	M.Div(M, C)             // ⎡2^(n+s)/c⎤
    	if M.Bit(int(n)) != 1 {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Mar 26 19:58:25 UTC 2024
    - 15.8K bytes
    - Viewed (0)
  6. src/math/big/int.go

    	x.abs.bytes(buf)
    	return buf
    }
    
    // BitLen returns the length of the absolute value of x in bits.
    // The bit length of 0 is 0.
    func (x *Int) BitLen() int {
    	// This function is used in cryptographic operations. It must not leak
    	// anything but the Int's sign and bit size through side-channels. Any
    	// changes must be reviewed by a security expert.
    	return x.abs.bitLen()
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 14 17:02:38 UTC 2024
    - 33.1K bytes
    - Viewed (0)
  7. src/crypto/x509/oid.go

    		o &= 0x7f
    		if i != 0 {
    			o |= 0x80
    		}
    		dst = append(dst, o)
    	}
    	return dst
    }
    
    func base128BigIntLength(n *big.Int) int {
    	if n.Cmp(big.NewInt(0)) == 0 {
    		return 1
    	}
    	return (n.BitLen() + 6) / 7
    }
    
    func appendBase128BigInt(dst []byte, n *big.Int) []byte {
    	if n.Cmp(big.NewInt(0)) == 0 {
    		return append(dst, 0)
    	}
    
    	for i := base128BigIntLength(n) - 1; i >= 0; i-- {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jun 04 19:10:38 UTC 2024
    - 8.3K bytes
    - Viewed (0)
  8. src/crypto/elliptic/elliptic.go

    // for ECDSA, use the GenerateKey function of the crypto/ecdsa package.
    func GenerateKey(curve Curve, rand io.Reader) (priv []byte, x, y *big.Int, err error) {
    	N := curve.Params().N
    	bitSize := N.BitLen()
    	byteLen := (bitSize + 7) / 8
    	priv = make([]byte, byteLen)
    
    	for x == nil {
    		_, err = io.ReadFull(rand, priv)
    		if err != nil {
    			return
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 13 17:09:47 UTC 2023
    - 9K bytes
    - Viewed (0)
  9. src/math/big/int_test.go

    		if z.Bit(i) == 0 {
    			t.Errorf("bitset: bit %d of %s got 0 want 1", i, x)
    		}
    		if z.Cmp(z1) != 0 {
    			t.Errorf("bitset: inconsistent value after SetBit 1, got %s want %s", z, z1)
    		}
    		z.SetBit(z, i, 0)
    		altSetBit(z1, z1, i, 0)
    		if z.Bit(i) != 0 {
    			t.Errorf("bitset: bit %d of %s got 1 want 0", i, x)
    		}
    		if z.Cmp(z1) != 0 {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 18:42:28 UTC 2024
    - 58.5K bytes
    - Viewed (0)
  10. src/crypto/rsa/rsa_test.go

    func TestKeyGeneration(t *testing.T) {
    	for _, size := range []int{128, 1024, 2048, 3072} {
    		priv, err := GenerateKey(rand.Reader, size)
    		if err != nil {
    			t.Errorf("GenerateKey(%d): %v", size, err)
    		}
    		if bits := priv.N.BitLen(); bits != size {
    			t.Errorf("key too short (%d vs %d)", bits, size)
    		}
    		testKeyBasics(t, priv)
    		if testing.Short() {
    			break
    		}
    	}
    }
    
    func Test3PrimeKeyGeneration(t *testing.T) {
    	size := 768
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jan 12 00:55:41 UTC 2024
    - 30.9K bytes
    - Viewed (0)
Back to top