---
name: "sub_of"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sub_of"
---

# sub\_of(3)

subtract two integers, check for arithmetic overflow

## NAME

sub\_of - subtract two integers, check for arithmetic overflow

## SYNTAX

**#include \<libowfat/rangecheck.h\>**

int **sub\_of**(dest,a,b);

## DESCRIPTION

If calculating a-b is possible without causing undefined behavior or an arithmetic overflow in C, and the result fits into the destination integer type, do dest=a-b and return 0.

Otherwise, return 1.

Note: This is a macro, so dest does not have to be a pointer.

## BUGS

In the multiplication functions, a return value of 1 signals success and 0 failure. In add\_of, sub\_of and assign it's the other way around.

## SEE ALSO

[add\_of(3)](/add_of/3.md), [assign(3)](/assign/3.md), [imult16(3)](/imult16/3.md), [umult16(3)](/umult16/3.md), [imult32(3)](/imult32/3.md), [umult32(3)](/umult32/3.md), [imult64(3)](/imult64/3.md), [umult64(3)](/umult64/3.md)
