xref: /original-bsd/lib/libc/quad/subdi3.c (revision 68d9582f)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This software was developed by the Computer Systems Engineering group
6  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7  * contributed to Berkeley.
8  *
9  * %sccs.include.redist.c%
10  */
11 
12 #if defined(LIBC_SCCS) && !defined(lint)
13 static char sccsid[] = "@(#)subdi3.c	5.4 (Berkeley) 06/02/92";
14 #endif /* LIBC_SCCS and not lint */
15 
16 #include "quad.h"
17 
18 /*
19  * Subtract two quad values.  This is trivial since a one-bit carry
20  * from a single u_long difference x-y occurs if and only if (x-y) > x.
21  */
22 quad
23 __subdi3(quad a, quad b)
24 {
25 	union uu aa, bb, diff;
26 
27 	aa.q = a;
28 	bb.q = b;
29 	diff.ul[L] = aa.ul[L] - bb.ul[L];
30 	diff.ul[H] = aa.ul[H] - bb.ul[H] - (diff.ul[L] > aa.ul[L]);
31 	return (diff.q);
32 }
33