xref: /freebsd-src/contrib/tcpdump/fptype.c (revision ee67461e56828dd1f8de165947ba83f6d9148a87)
1*ee67461eSJoseph Mingrone /*
2*ee67461eSJoseph Mingrone  * Copyright (c) 1982, 1986, 1993
3*ee67461eSJoseph Mingrone  *	The Regents of the University of California.  All rights reserved.
4*ee67461eSJoseph Mingrone  *
5*ee67461eSJoseph Mingrone  * Redistribution and use in source and binary forms, with or without
6*ee67461eSJoseph Mingrone  * modification, are permitted provided that the following conditions
7*ee67461eSJoseph Mingrone  * are met:
8*ee67461eSJoseph Mingrone  * 1. Redistributions of source code must retain the above copyright
9*ee67461eSJoseph Mingrone  *    notice, this list of conditions and the following disclaimer.
10*ee67461eSJoseph Mingrone  * 2. Redistributions in binary form must reproduce the above copyright
11*ee67461eSJoseph Mingrone  *    notice, this list of conditions and the following disclaimer in the
12*ee67461eSJoseph Mingrone  *    documentation and/or other materials provided with the distribution.
13*ee67461eSJoseph Mingrone  * 3. All advertising materials mentioning features or use of this software
14*ee67461eSJoseph Mingrone  *    must display the following acknowledgement:
15*ee67461eSJoseph Mingrone  *	This product includes software developed by the University of
16*ee67461eSJoseph Mingrone  *	California, Berkeley and its contributors.
17*ee67461eSJoseph Mingrone  * 4. Neither the name of the University nor the names of its contributors
18*ee67461eSJoseph Mingrone  *    may be used to endorse or promote products derived from this software
19*ee67461eSJoseph Mingrone  *    without specific prior written permission.
20*ee67461eSJoseph Mingrone  *
21*ee67461eSJoseph Mingrone  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22*ee67461eSJoseph Mingrone  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23*ee67461eSJoseph Mingrone  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24*ee67461eSJoseph Mingrone  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25*ee67461eSJoseph Mingrone  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26*ee67461eSJoseph Mingrone  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27*ee67461eSJoseph Mingrone  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28*ee67461eSJoseph Mingrone  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29*ee67461eSJoseph Mingrone  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30*ee67461eSJoseph Mingrone  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31*ee67461eSJoseph Mingrone  * SUCH DAMAGE.
32*ee67461eSJoseph Mingrone  */
33*ee67461eSJoseph Mingrone 
34*ee67461eSJoseph Mingrone #include <stdio.h>
35*ee67461eSJoseph Mingrone 
36*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
37*ee67461eSJoseph Mingrone 
38*ee67461eSJoseph Mingrone #include "fptype.h"
39*ee67461eSJoseph Mingrone 
40*ee67461eSJoseph Mingrone void
float_type_check(uint32_t in)41*ee67461eSJoseph Mingrone float_type_check(uint32_t in)
42*ee67461eSJoseph Mingrone {
43*ee67461eSJoseph Mingrone 	union { /* int to float conversion buffer */
44*ee67461eSJoseph Mingrone 		float f;
45*ee67461eSJoseph Mingrone 		uint32_t i;
46*ee67461eSJoseph Mingrone 	} f;
47*ee67461eSJoseph Mingrone 
48*ee67461eSJoseph Mingrone 	f.i = in;
49*ee67461eSJoseph Mingrone 	printf("%.3f\n", f.f*8/1000000);
50*ee67461eSJoseph Mingrone }
51