Home | History | Annotate | Download | only in common
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     23 
     24 /*
     25  * Copyright (c) 1988 by Sun Microsystems, Inc.
     26  */
     27 
     28 /*
     29  * Conversion between single, and extended binary and decimal
     30  * floating point - separated from double_to_decimal to minimize impact on
     31  * main(){printf("Hello");}
     32  */
     33 
     34 #include "base_conversion.h"
     35 
     36 void
     37 single_to_decimal(px, pm, pd, ps)
     38 	single         *px;
     39 	decimal_mode   *pm;
     40 	decimal_record *pd;
     41 	fp_exception_field_type *ps;
     42 {
     43 	single_equivalence kluge;
     44 	unpacked        u;
     45 
     46 	*ps = 0;		/* Initialize *ps - no exceptions. */
     47 	kluge.x = *px;
     48 	pd->sign = kluge.f.msw.sign;
     49 	pd->fpclass = _class_single(px);
     50 	switch (pd->fpclass) {
     51 	case fp_zero:
     52 		break;
     53 	case fp_infinity:
     54 		break;
     55 	case fp_quiet:
     56 		break;
     57 	case fp_signaling:
     58 		break;
     59 	default:
     60 		_unpack_single(&u, &kluge.x);
     61 		_unpacked_to_decimal(&u, pm, pd, ps);
     62 	}
     63 }
     64 
     65 void
     66 extended_to_decimal(px, pm, pd, ps)
     67 	extended       *px;
     68 	decimal_mode   *pm;
     69 	decimal_record *pd;
     70 	fp_exception_field_type *ps;
     71 {
     72 	extended_equivalence kluge;
     73 	unpacked        u;
     74 
     75 	*ps = 0;		/* Initialize *ps - no exceptions. */
     76 	kluge.x[0] = (*px)[0];
     77 	kluge.x[1] = (*px)[1];
     78 	kluge.x[2] = (*px)[2];
     79 	pd->sign = kluge.f.msw.sign;
     80 	pd->fpclass = _class_extended(px);
     81 	switch (pd->fpclass) {
     82 	case fp_zero:
     83 		break;
     84 	case fp_infinity:
     85 		break;
     86 	case fp_quiet:
     87 		break;
     88 	case fp_signaling:
     89 		break;
     90 	default:
     91 		_unpack_extended(&u, px);
     92 		_unpacked_to_decimal(&u, pm, pd, ps);
     93 	}
     94 }
     95