xref: /onnv-gate/usr/src/lib/libc/port/gen/llog10.c (revision 6812:febeba71273d)
1*6812Sraf /*
2*6812Sraf  * CDDL HEADER START
3*6812Sraf  *
4*6812Sraf  * The contents of this file are subject to the terms of the
5*6812Sraf  * Common Development and Distribution License (the "License").
6*6812Sraf  * You may not use this file except in compliance with the License.
7*6812Sraf  *
8*6812Sraf  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6812Sraf  * or http://www.opensolaris.org/os/licensing.
10*6812Sraf  * See the License for the specific language governing permissions
11*6812Sraf  * and limitations under the License.
12*6812Sraf  *
13*6812Sraf  * When distributing Covered Code, include this CDDL HEADER in each
14*6812Sraf  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6812Sraf  * If applicable, add the following below this CDDL HEADER, with the
16*6812Sraf  * fields enclosed by brackets "[]" replaced with your own identifying
17*6812Sraf  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6812Sraf  *
19*6812Sraf  * CDDL HEADER END
20*6812Sraf  */
21*6812Sraf 
22*6812Sraf /*
23*6812Sraf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*6812Sraf  * Use is subject to license terms.
25*6812Sraf  */
26*6812Sraf 
27*6812Sraf /*	Copyright (c) 1988 AT&T	*/
28*6812Sraf /*	  All Rights Reserved  	*/
29*6812Sraf 
30*6812Sraf #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*6812Sraf 
32*6812Sraf #include	"lint.h"
33*6812Sraf #include	<sys/types.h>
34*6812Sraf #include	<sys/dl.h>
35*6812Sraf 
36*6812Sraf dl_t
llog10(dl_t val)37*6812Sraf llog10(dl_t val)
38*6812Sraf {
39*6812Sraf 	dl_t	result;
40*6812Sraf 
41*6812Sraf 	result = lzero;
42*6812Sraf 	val    = ldivide(val, lten);
43*6812Sraf 
44*6812Sraf 	while (val.dl_hop != 0 || val.dl_lop != 0) {
45*6812Sraf 		val = ldivide(val, lten);
46*6812Sraf 		result = ladd(result, lone);
47*6812Sraf 	}
48*6812Sraf 
49*6812Sraf 	return (result);
50*6812Sraf }
51