---
name: "libressl-BN_cmp"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-BN_cmp"
---

# libressl-BN\_cmp(3)

BIGNUM comparison and test functions

## NAME

**BN\_cmp**, **BN\_ucmp**, **BN\_is\_zero**, **BN\_is\_one**, **BN\_is\_word**, **BN\_abs\_is\_word**, **BN\_is\_odd** – BIGNUM comparison and test functions

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/bn.h\>**

*int*\

**BN\_cmp**(*const BIGNUM \*a*, *const BIGNUM \*b*);

*int*\

**BN\_ucmp**(*const BIGNUM \*a*, *const BIGNUM \*b*);

*int*\

**BN\_is\_zero**(*const BIGNUM \*a*);

*int*\

**BN\_is\_one**(*const BIGNUM \*a*);

*int*\

**BN\_is\_word**(*const BIGNUM \*a*, *const BN\_ULONG w*);

*int*\

**BN\_abs\_is\_word**(*const BIGNUM \*a*, *const BN\_ULONG w*);

*int*\

**BN\_is\_odd**(*const BIGNUM \*a*);

## DESCRIPTION

**BN\_cmp**() compares the numbers *a* and *b*. **BN\_ucmp**() compares their absolute values.

**BN\_is\_zero**(), **BN\_is\_one**() and **BN\_is\_word**() test if *a* equals 0, 1, or *w* respectively. **BN\_abs\_is\_word**() tests if the absolute value of *a* equals *w*. **BN\_is\_odd**() tests if a is odd.

*BN\_ULONG* is a macro that expands to *unsigned* *long* (= *uint64\_t*) on \_LP64 platforms and *unsigned* *int* (= *uint32\_t*) elsewhere.

## RETURN VALUES

**BN\_cmp**() returns -1 if *a*\<*b*, 0 if *a*==*b*, and 1 if *a*\>*b*. **BN\_ucmp**() is the same using the absolute values of *a* and *b*.

**BN\_is\_zero**(), **BN\_is\_one**(), **BN\_is\_word**(), **BN\_abs\_is\_word**(), and **BN\_is\_odd**() return 1 if the condition is true, 0 otherwise.

## SEE ALSO

BN\_new(3)

## HISTORY

**BN\_cmp**(), **BN\_ucmp**(), **BN\_is\_zero**(), **BN\_is\_one**(), and **BN\_is\_word**() first appeared in SSLeay 0.5.1. **BN\_is\_odd**() first appeared in SSLeay 0.8.0. These functions have been available since OpenBSD 2.4.

**BN\_abs\_is\_word**() first appeared in OpenSSL 0.9.7 and has been available since OpenBSD 3.2.
