533c8f928dcceea13126db893785cfc70e901a3e
[unix-history] / usr / src / lib / libc / quad / subdi3.c
/*-
* Copyright (c) 1992 The Regents of the University of California.
* All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* %sccs.include.redist.c%
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)subdi3.c 5.4 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
#include "quad.h"
/*
* Subtract two quad values. This is trivial since a one-bit carry
* from a single u_long difference x-y occurs if and only if (x-y) > x.
*/
quad
__subdi3(quad a, quad b)
{
union uu aa, bb, diff;
aa.q = a;
bb.q = b;
diff.ul[L] = aa.ul[L] - bb.ul[L];
diff.ul[H] = aa.ul[H] - bb.ul[H] - (diff.ul[L] > aa.ul[L]);
return (diff.q);
}