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