In article <11c8dls$2chr0$1@dont-email.me>,
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
On 2026-10-29 17:55, Janis Papanagnou wrote:
On 2026-10-29 20:49, Dan Cross wrote:
[...]
But again, the whole premise (that a programmer familiar with C
would ever think that `return` is a function) is silly.
Agreed. The misconception is far more common among those
who aren't very familiar with C.
It is not common at all.
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
David Brown <david.brown@hesbynett.no> writes:
On 28/10/2026 21:25, Michael S wrote:
[...]
I'd still likely prefer to write it as (float)0.1 instead of 0.1f.
It somewhat depends on my mood in specific day, but likelihood is
certainly not in favor of 0.1f.
That seems a bit excessive to me, but okay. The principle is the
same, making it clear to the reader and the compiler that no
double-precision arithmetic is involved.
Except that, at least in the abstract machine, `(float)0.1` produces
a value of type double and converts it to float. It's likely that
a compiler would generate the same code as for `0.1f`, but I'd want
to confirm that if it mattered. (Actually, I'd just write `0.1f`.)
Maybe the code will be the same. But in general going via doubles
produces less accurate result, [...]
antispam@fricas.org (Waldek Hebisch) writes:
Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
David Brown <david.brown@hesbynett.no> writes:
On 28/10/2026 21:25, Michael S wrote:
[...]
I'd still likely prefer to write it as (float)0.1 instead of 0.1f.
It somewhat depends on my mood in specific day, but likelihood is
certainly not in favor of 0.1f.
That seems a bit excessive to me, but okay. The principle is the
same, making it clear to the reader and the compiler that no
double-precision arithmetic is involved.
Except that, at least in the abstract machine, `(float)0.1` produces
a value of type double and converts it to float. It's likely that
a compiler would generate the same code as for `0.1f`, but I'd want
to confirm that if it mattered. (Actually, I'd just write `0.1f`.)
Maybe the code will be the same. But in general going via doubles
produces less accurate result, [...]
What makes you think using a double will produce a less accurate
result?
On 2026-11-03, Dan Cross <cross@spitfire.i.gajendra.net> wrote:
In article <11c8dls$2chr0$1@dont-email.me>,
James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
On 2026-10-29 17:55, Janis Papanagnou wrote:
On 2026-10-29 20:49, Dan Cross wrote:
[...]
But again, the whole premise (that a programmer familiar with C
would ever think that `return` is a function) is silly.
Agreed. The misconception is far more common among those
who aren't very familiar with C.
It is not common at all.
You have to get to a certain advanced level of education in computer
science before you start believing that returning is another function
calls.
But it's there. The returning control flow can be modeled by
continuations.
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.
| Sysop: | Jacob Catayoc |
|---|---|
| Location: | Pasay City, Metro Manila, Philippines |
| Users: | 5 |
| Nodes: | 4 (0 / 4) |
| Uptime: | 498678:30:03 |
| Calls: | 212 |
| Calls today: | 3 |
| Files: | 912 |
| D/L today: |
31 files (22,593K bytes) |
| Messages: | 69,867 |