Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!uflorida!haven!adm!smoke!gwyn
From: gwyn@smoke.BRL.MIL (Doug Gwyn)
Newsgroups: comp.lang.c
Subject: Re: cast'ing unions
Message-ID: <10710@smoke.BRL.MIL>
Date: 11 Aug 89 21:05:45 GMT
References: <2189@stl.stc.co.uk>
Reply-To: gwyn@brl.arpa (Doug Gwyn)
Organization: Ballistic Research Lab (BRL), APG, MD.
Lines: 12

In article <2189@stl.stc.co.uk> dsr@stl.stc.co.uk (David Riches's friend) writes:
>ie float num = (float) u ;

This shows a misunderstanding not only of unions but also of casts.
A cast performs a conversion between two data types, while a union
allows multiple data types to be stored in overlapping locations
(only one type at a time is valid, though; if you store a type into
a union you need to fetch the data as the same type as was stored).

Just use	num = u.f;
or		num = (float) u.i;
depending on which one you really mean.