Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!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: routine for angles needed Date: Mon, 03 Aug 2015 18:30:03 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <981bdb46-3ced-4e3c-9dcf-194ecfc029ba@googlegroups.com> <8fde3a91-d5d5-475c-b4ad-deedf78da009@googlegroups.com> <3840e0cd-5109-4e45-954b-87f36583efa6@googlegroups.com> <94c50de4-6c20-483a-9236-3f187ee7df3e@googlegroups.com> <16138ae3-5e39-4347-8d0a-4a82bbdf0f8c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="17674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19sYGiaFWkMe45jzyzWW2bt" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:1Rj4Cvxqcn2fjPvk4L5tGsAennM= sha1:Etux0C3xXIRiq5bobae6PqFqFfY= Xref: csiph.com comp.lang.c:66831 Bartc writes: > On 03/08/2015 21:44, Keith Thompson wrote: >> Bartc writes: >> [...] >>> C uses binary floating point. >> [...] >> >> Most (probably nearly all) C implementations use binary floating-point. >> The standard permits other bases, which is why FLT_RADIX exists. >> >> Some IBM mainframe systems use base 16 -- which has most of the >> characteristics of binary, but the precision fluctuates more depending >> on the exponent value. Base 10 floating-point is not unheard of. > > Using that knowledge, that there might be systems for which C doesn't > use binary FP, would you be able to say that fmod(9.0,3.33) gives > exactly 2.34? > > Probably not... Certainly you couldn't rely on it. Certainly not. On my system it yields 2.339999999999999857891452847979962825775146484375 or equivalently 0x1.2b851eb851eb8p+1 On a system where FLT_RADIX == 10 (or is a power of 10), fmod(9.0, 3.33) probably would be exactly 2.34. -- 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"