Article View: comp.lang.c
Article #1109Re: .5 against 0.5f
From: David Brown
Date: Thu, 29 Oct 2026 10:06
Date: Thu, 29 Oct 2026 10:06
33 lines
2783 bytes
2783 bytes
On 28/10/2026 22:34, Chris M. Thomasson wrote: > On 10/28/2026 12:39 AM, David Brown wrote: >> On 28/10/2026 01:49, Lawrence D’Oliveiro wrote: >>> On Tue, 27 Oct 2026 18:06:25 -0400, James Kuyper wrote: >>> >>>> However, if you need double precision, you shouldn't be using the >>>> "f" suffix. >>> >>> Is there any situation where you *should* use the “f” suffix? >>> >>> I am thinking: no. >> >> Try thinking harder. >> >> I use the "f" suffix all the time in my code, because I do not want >> double precision. In many situations, single precision arithmetic is >> at least twice as fast as double precision - in some situations it can >> be two orders of magnitude faster. >> >> > > Same here. I am mostly creating graphics related things. double > precision in a GPU might not be there. Now, if I am doing something that > needs higher precision, tends to be with deep zooms or granularity in a > vector field, then double is okay. But I need to beware that the shaders > might not support double. You can also see it in SIMD. A 128-bit SIMD register might be useable for 4 single-precision values and parallel operations, while only 2 can be handled for double-precision. Obviously details will vary by SIMD implementation, but singles are going to be at least twice as fast in general.
Technical Details
Message-ID:
<11bv5rl$37s52$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11bs8rb$26dq0$1@dont-email.me> <11btppc$2qhsd$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: .5 against 0.5f Date: Thu, 29 Oct 2026 11:06:44 +0100 Organization: A noiseless patient Spider Lines: 33 Message-ID: <11bv5rl$37s52$1@dont-email.me> References: <11bpvs7$1e6kc$2@dont-email.me> <11bqnvh$1np7s$1@dont-email.me> <11br5td$1to7l$1@dont-email.me> <11br792$1u7e5$1@dont-email.me> <11brgqf$21170$2@dont-email.me> <11bs8rb$26dq0$1@dont-email.me> <11btppc$2qhsd$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 29 Oct 2026 10:06:46 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3403938"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lw8bEfcYkyX9+Fbsqyz/rjBPs21L9bRU="; posting-host="ee186c62f9168531a82b8aa89ffdfee0" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:24PgzWPJbm/zsmDNRqldw/z+4os= sha256:8z3joBOZAVOV4ciWLzZKYyUrzrIoefGaOKHfJQ5qo0s= sha1:A/XW7frM3WeFe2UFak0h/5SeLRc= sha256:d5uiqZA8ucGOeSO2xYyEztpg+Q7cpXg3Z0LK7GPI3Yo= In-Reply-To: <11btppc$2qhsd$1@dont-email.me> Content-Language: en-GB, nb-NO