Path: csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Objective C Date: Sun, 15 Nov 2015 10:56:02 -0800 Organization: None to speak of Lines: 38 Message-ID: References: <829a44d6-a605-4d49-87d0-04fa9d2a2a0a@googlegroups.com> <3f7e3553-b5b3-45a7-9a3e-d2b18c7268a4@googlegroups.com> <2e08fc7d-3253-404c-b04f-b624c3550c8f@googlegroups.com> <663e513b-b739-4e17-a175-642a3bd49283@googlegroups.com> <49e74554-a5a2-4441-9676-2e59118b1079@googlegroups.com> <40031c30-7a37-495b-990c-af271a82aa2d@googlegroups.com> <55613c36-e3f3-4b26-b654-4b543e1acfdb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="5702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qCfs7u/atx6Qy/b13Jahm" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:CyRz5IsCQxN9oCV2Cuklbn7oCi4= sha1:IfisnEPFN9TAYfgDLLxW7dxJLHc= Xref: csiph.com comp.lang.c:76106 Malcolm McLean writes: > On Saturday, November 14, 2015 at 11:39:56 PM UTC, Keith Thompson wrote: >> Malcolm McLean writes: >> How do you convert a float to int? >> >> float f = 42.0; >> int i = f; >> >> How do you print a human-readable representation of a float value? >> >> printf("%f\n", f); >> >> How are strict aliasing / effective type rules relevant to any of this? >> My point is that Alla, and other novice C programmers, don't need to >> worry about any of that. (I rarely worry about it myself.) >> > If you're content to say they work by magic, then fair enough. > But if you want to understand what's going on, you have to > explain it in terms of reinterpretation of bits, or aliasing. I don't have much to add to the other responses you've gotten. I'll just say that operating on floating-point values and objects, including converting a float value to int (and I mean the kind of conversion that converts 42.0 to 42) and generating a human-readable string representation of a floating-point value, does not require reinterpretation of the bits making up the representation of a floating-point value or object. And I have no idea why you think it does. The context here is whether a novice C programmer needs to worry about aliasing. The points you introduce are (a) beyond anything a novice C programmer needs to worry about and (b) wrong. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"