• .5 against 0.5f

    From fir@3:633/10 to All on Tue Oct 27 11:53:55 2026
    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Tue Oct 27 17:45:21 2026
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Tue Oct 27 18:50:09 2026
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html



    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes
    on floats) why the ai so maniacally puts that f?


    i gues the answer is NOT but maybe soem can show at least one case it
    could be worse?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Tue Oct 27 18:40:52 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Tue Oct 27 19:01:36 2026
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes code
    easier to read. The difference between 0.1 and 0.1f with their binary
    representations is a another matter.

    #include <stdio.h>

    int main(void)
    {
    double d;
    d = 0.1f; printf("%.13a\n", d);
    d = 0.1; printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z 0x1.99999a0000000p-4 0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Here is your answer.

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes
    on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with
    the propagation of floating point errors, the only answer that one can
    give for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a
    float type. Why not ask AI why it appends the f?

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Tue Oct 27 20:15:20 2026
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and >>>> yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes code
    easier to read. The difference between 0.1 and 0.1f with their binary
    representations is a another matter.

    #include <stdio.h>

    int main(void)
    {
    double d;
    d = 0.1f; printf("%.13a\n", d);
    d = 0.1; printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z 0x1.99999a0000000p-4 0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Here is your answer.

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes
    on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with
    the propagation of floating point errors, the only answer that one can
    give for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a
    float type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double


    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive

    (i some cases ai not quite tells the truth and i cant easily validate it)

    it also not gives stright answe if pushed - it says more liek id depends
    on flags, compiler may or may

    so this is no good answer

    (and i asume there may be soem simple answer here i dont know
    (and i suspect its rather - no it will generate float no silly conversions

    if no that would be bad)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Tue Oct 27 12:29:43 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    Send them an email saying you were overcharged and want a refund
    of 0.000000000001 cents. ;)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Tue Oct 27 21:43:42 2026
    On Tue, 27 Oct 2026 18:40:52 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the
    and yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may
    it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    At least, unlike favorite AI of fir, Amazon was not using
    single-precision.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Tue Oct 27 19:54:11 2026
    On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    (snip)

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in
    code not doubles, and the code is a bit time critical like
    rasterisation goes on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with the
    propagation of floating point errors, the only answer that one can give
    for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a float
    type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double

    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive


    I do not know where to begin to address the above. Perhaps,
    find a copy of K&R to read.

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Tue Oct 27 19:58:57 2026
    On 2026-10-27, Steven G. Kargl <sgk@REMOVEtroutmask.apl.washington.edu> wrote:
    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format.

    The real number 0.1 has a worse approximation in float than double,
    (if those are not the same size).

    However, every representation in float is supposed to be available
    in double: float to double conversion is lossless.

    If you write double d = 0.1f you are essentially saying you want d to
    take on that approximation of 0.1 that is available in float,
    rather than a possibly better one available in double.

    The abstract semantics is that 0.1f is a constant of type float.
    The actual semantics may be that the compiler notices that the
    float is used as an initialize for a double, and so just convert
    to a double constant of the same value.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Tue Oct 27 22:05:06 2026
    On Tue, 27 Oct 2026 21:43:42 +0200
    Michael S <already5chosen@yahoo.com> wrote:

    On Tue, 27 Oct 2026 18:40:52 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at
    the and yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is
    may it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe
    occupies some more memory (?) or uses some casting in
    coplutations (?)


    i doubt it probably it makes difference but im strictly not sure


    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point
    arithmetic for pricing.

    At least, unlike favorite AI of fir, Amazon was not using
    single-precision.




    BTW, 75.71000000000001 looks like 67 * 1.13 in IEEE binary64, but
    rounded up rather than to nearest.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Tue Oct 27 20:05:44 2026
    On 2026-10-27, Scott Lurndal <scott@slp53.sl.home> wrote:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    That reminds of a joke I have in the TXR Lisp fortune module,
    intended for displaying a random quip at REPL startup.

    Oh, look, I got it after just a couple of tries:

    This is the TXR Lisp interactive listener of TXR 302.
    Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
    (quip)
    "Coding around Unicode grapheme clusters is a character-building exercise."
    (quip)
    "defmicro: error: expansion is larger than original form: switch to defmacro."
    (prinl (quip))
    "This could be the year of the TXR desktop; I can feel it!"
    "This could be the year of the TXR desktop; I can feel it!"
    (put-line (quip))
    TXR kind of supports IEEE 754.00000000000003 floating-point.
    t

    :)

    FP is fine for pricing: look at how ridiculously close to 75.71
    the above approximation is. You just have to make sure never to
    let enough error accumulate so that an intermediate value
    is suddenly closer to the wrong penny value than the right one.
    (Actually you don't even want to get anywhere near that level
    of error.)

    If all your system does is take a value from a ledger, do a few simple calcluations on it, then round it to the best approximation of the nearest penny before recording back into the ledger, you are fine. You then just have to be careful about converting the values to digits.


    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Oct 27 13:08:00 2026
    On 10/27/2026 3:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Why not ask the ai, again... ;^)

    0.1f == .1f


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Oct 27 13:10:58 2026
    On 10/27/2026 12:54 PM, Steven G. Kargl wrote:
    On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    (snip)

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in
    code not doubles, and the code is a bit time critical like
    rasterisation goes on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with the
    propagation of floating point errors, the only answer that one can give
    for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a float
    type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double

    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive


    I do not know where to begin to address the above. Perhaps,
    find a copy of K&R to read.


    Oh, but the ai is his nest of books. Almost like the tommyknockers from Stephen King. The residents of Haven started making things that they did
    not understand at all.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Oct 27 13:11:48 2026
    On 10/27/2026 12:29 PM, Tim Rentsch wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    Send them an email saying you were overcharged and want a refund
    of 0.000000000001 cents. ;)

    ROFL!

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Oct 27 13:25:06 2026
    On 10/27/2026 1:11 PM, Chris M. Thomasson wrote:
    On 10/27/2026 12:29 PM, Tim Rentsch wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    ˙˙˙ Total
    ˙˙˙ 75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    Send them an email saying you were overcharged and want a refund
    of 0.000000000001 cents.˙ ;)

    ROFL!

    Must have just watched superman 3? ;^)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Tue Oct 27 21:35:48 2026
    On 27/10/2026 20:54, Steven G. Kargl wrote:
    On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    (snip)

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in
    code not doubles, and the code is a bit time critical like
    rasterisation goes on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with the
    propagation of floating point errors, the only answer that one can give
    for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a float
    type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double

    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive


    I do not know where to begin to address the above. Perhaps,
    find a copy of K&R to read.


    For your benefit (not for Fir's), the multiplication of "a * 1.5" would
    be done in double precision (unless "a" is a "long double"). The
    resulting double value would then be converted to a single-precision float.

    Whether "a * 1.5f" is done as single (float) or double depends on the
    type of "a" - if it is a "double", then the float value 1.5f gets
    converted to a double (and may be slightly different from 1.5) and the multiplication is done as double precision. If "a" is of type "float",
    then the multiplication is done as single precision.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Tue Oct 27 22:51:41 2026
    On Tue, 27 Oct 2026 22:05:06 +0200
    Michael S <already5chosen@yahoo.com> wrote:

    On Tue, 27 Oct 2026 21:43:42 +0200
    Michael S <already5chosen@yahoo.com> wrote:

    On Tue, 27 Oct 2026 18:40:52 GMT
    scott@slp53.sl.home (Scott Lurndal) wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu>
    writes:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at
    the and yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is
    may it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe
    occupies some more memory (?) or uses some casting in
    coplutations (?)


    i doubt it probably it makes difference but im strictly not
    sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    #include <stdio.h>

    int
    main(void)
    {
    double d;
    d = 0.1f;
    printf("%.13a\n", d);
    d = 0.1;
    printf("%.13a\n", d);
    return (0);
    }

    % cc -o z t.c && ./z
    0x1.99999a0000000p-4
    0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary >floating point format. See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html


    I ordered a couple of blu-rays from amazon last week, and the confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point
    arithmetic for pricing.

    At least, unlike favorite AI of fir, Amazon was not using
    single-precision.




    BTW, 75.71000000000001 looks like 67 * 1.13 in IEEE binary64, but
    rounded up rather than to nearest.


    Or 67 + 67 * 0.13 rounded to nearest.





    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Tue Oct 27 21:57:53 2026
    fir pisze:
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and >>>>> yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it >>>>> give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes code
    easier to read.˙ The difference between 0.1 and 0.1f with their binary >>>> representations is a another matter.

    #include <stdio.h>

    int main(void)
    {
    ˙˙˙˙ double d;
    ˙˙˙˙ d = 0.1f; printf("%.13a\n", d);
    ˙˙˙˙ d = 0.1; printf("%.13a\n", d);
    ˙˙˙˙ return (0);
    }

    % cc -o z t.c && ./z 0x1.99999a0000000p-4 0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format.˙ See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    ˙˙˙ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ˙˙˙ Here is your answer.

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes >>> on floats)˙ why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with
    the propagation of floating point errors, the only answer that one can
    give for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a
    float type.˙ Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double


    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive

    (i some cases ai not quite tells the truth and i cant easily validate it)

    it also not gives stright answe if pushed - it says more liek id depends
    on flags, compiler may or may

    so this is no good answer

    (and i asume there may be soem simple answer here i dont know
    (and i suspect its rather - no it will generate float no silly conversions

    if no that would be bad)


    ai is besides obviously great - it just drawed me even a small cosmonaut
    right now

    https://www.youtube.com/watch?v=aZ1F4soMRHE


    its code is not even long




    static float3 astronaut_v[512];
    static int astronaut_tri[1024][3];
    static unsigned astronaut_color[1024];
    static int astronaut_vertex_count=0;
    static int astronaut_triangle_count=0;
    static int astronaut_initialized=0;

    void AstronautVertex(float x,float y,float z)
    {
    if(astronaut_vertex_count>=512) return;
    astronaut_v[astronaut_vertex_count++]=f3(x,y,z);
    }

    void AstronautTriangle(int a,int b,int c,unsigned color)
    {
    if(astronaut_triangle_count>=1024) return;
    int i=astronaut_triangle_count++;
    astronaut_tri[i][0]=a;
    astronaut_tri[i][1]=b;
    astronaut_tri[i][2]=c;
    astronaut_color[i]=color;
    }

    void AstronautQuad(int a,int b,int c,int d,unsigned color)
    {
    AstronautTriangle(a,b,c,color);
    AstronautTriangle(a,c,d,color);
    }

    void AstronautBox(float x,float y,float z,float sx,float sy,float
    sz,unsigned color)
    {
    int b=astronaut_vertex_count;
    if(b+8>512 || astronaut_triangle_count+12>1024) return;

    AstronautVertex(x-sx,y-sy,z-sz);
    AstronautVertex(x+sx,y-sy,z-sz);
    AstronautVertex(x+sx,y+sy,z-sz);
    AstronautVertex(x-sx,y+sy,z-sz);
    AstronautVertex(x-sx,y-sy,z+sz);
    AstronautVertex(x+sx,y-sy,z+sz);
    AstronautVertex(x+sx,y+sy,z+sz);
    AstronautVertex(x-sx,y+sy,z+sz);

    AstronautQuad(b,b+3,b+2,b+1,color);
    AstronautQuad(b+4,b+5,b+6,b+7,color);
    AstronautQuad(b,b+1,b+5,b+4,color);
    AstronautQuad(b+1,b+2,b+6,b+5,color);
    AstronautQuad(b+2,b+3,b+7,b+6,color);
    AstronautQuad(b+3,b,b+4,b+7,color);
    }

    void AstronautBuild(void)
    {
    if(astronaut_initialized) return;
    astronaut_vertex_count=0;
    astronaut_triangle_count=0;

    // Buty.
    AstronautBox(-4,24,1,3.5f,3,5.5f,0x343b43);
    AstronautBox( 4,24,1,3.5f,3,5.5f,0x343b43);
    AstronautBox(-4,22.5f,3,3.2f,1.1f,3.5f,0x68747d);
    AstronautBox( 4,22.5f,3,3.2f,1.1f,3.5f,0x68747d);

    // Nogi i kolana.
    AstronautBox(-4,17,0,2.8f,5.5f,3.5f,0xd5d8d6);
    AstronautBox( 4,17,0,2.8f,5.5f,3.5f,0xd5d8d6);
    AstronautBox(-4,11,0,3,2.3f,3.8f,0x626c74);
    AstronautBox( 4,11,0,3,2.3f,3.8f,0x626c74);
    AstronautBox(-4,7,0,2.8f,3.8f,3.3f,0xe1e2dc);
    AstronautBox( 4,7,0,2.8f,3.8f,3.3f,0xe1e2dc);
    AstronautBox(-4,17,3.5f,2.4f,0.9f,0.7f,0xf28a32);
    AstronautBox( 4,17,3.5f,2.4f,0.9f,0.7f,0xf28a32);

    // Tu?˘w i kombinezon.
    AstronautBox(0,-1,0,7,9,4.5f,0xd9dcd8);
    AstronautBox(0,-1,4.2f,5.5f,6.5f,0.8f,0xb5c0c2);
    AstronautBox(0,-1,5,3.7f,3.5f,0.5f,0x303b43);

    // Panel sterowania na piersi.
    AstronautBox(0,-3,5.65f,2.8f,2.6f,0.35f,0x505c64);
    AstronautBox(-1,-3.5f,6.05f,0.65f,0.65f,0.15f,0xf28a32);
    AstronautBox( 1,-3.5f,6.05f,0.65f,0.65f,0.15f,0x5a9bb5);
    AstronautBox(-1,-1.9f,6.05f,0.4f,0.35f,0.15f,0xd8d8d0);
    AstronautBox( 1,-1.9f,6.05f,0.4f,0.35f,0.15f,0xd8d8d0);

    // Pas i boczne kieszenie.
    AstronautBox(0,5,0,7.2f,1.3f,4.8f,0x424b52);
    AstronautBox(-6,2,0,1.5f,2.2f,3.5f,0x778087);
    AstronautBox( 6,2,0,1.5f,2.2f,3.5f,0x778087);
    AstronautBox(-6,2,3.4f,0.8f,1.4f,0.5f,0xf28a32);
    AstronautBox( 6,2,3.4f,0.8f,1.4f,0.5f,0xf28a32);

    // Plecak za tu?owiem.
    AstronautBox(0,-1,-5.5f,5.5f,7.5f,2.5f,0x69747b);
    AstronautBox(0,-1,-8,4.2f,5.5f,0.5f,0x343e47);
    AstronautBox(-3,-1,-8.6f,0.8f,4,0.4f,0xf28a32);
    AstronautBox( 3,-1,-8.6f,0.8f,4,0.4f,0xf28a32);
    AstronautBox(0,-6,-8.3f,2.5f,1,0.4f,0xbac2c3);
    AstronautBox(0, 4,-8.3f,2.5f,1,0.4f,0xbac2c3);

    // Ramiona.
    AstronautBox(-9,-3,0,3,5,3.5f,0xd8dbd7);
    AstronautBox( 9,-3,0,3,5,3.5f,0xd8dbd7);
    AstronautBox(-9,-6,0,3.1f,1,3.8f,0xf28a32);
    AstronautBox( 9,-6,0,3.1f,1,3.8f,0xf28a32);
    AstronautBox(-11,-1,0,2.1f,4,3,0xd8dbd7);
    AstronautBox( 11,-1,0,2.1f,4,3,0xd8dbd7);

    // R?kawice.
    AstronautBox(-12,3,0,2.2f,2.5f,2.7f,0x505b64);
    AstronautBox( 12,3,0,2.2f,2.5f,2.7f,0x505b64);
    AstronautBox(-12,3,2.1f,1.6f,1.7f,0.7f,0x7d878d);
    AstronautBox( 12,3,2.1f,1.6f,1.7f,0.7f,0x7d878d);

    // Szyja i pier?cie? he?mu.
    AstronautBox(0,-10,0,4,1.5f,4,0x6a747b);
    AstronautBox(0,-11,0,5.6f,1.2f,5.6f,0x858e94);
    AstronautBox(0,-11,0,4.7f,0.7f,4.7f,0xf28a32);

    // Kask.
    AstronautBox(0,-17,0,6.5f,6,5.5f,0xdde0dc);
    AstronautBox(0,-17,4.5f,5.3f,4.2f,1.5f,0x303b43);
    AstronautBox(0,-17,5.8f,4.4f,3.2f,0.5f,0x111d2a);
    AstronautBox(0,-17,6.1f,3.7f,2.5f,0.3f,0x16435c);
    // Boki kasku i mocowania.
    AstronautBox(-6.6f,-17,0,1.2f,2.8f,2.8f,0x69757d);
    AstronautBox( 6.6f,-17,0,1.2f,2.8f,2.8f,0x69757d);
    AstronautBox(-7.2f,-17,0,0.7f,2,2,0xf28a32);
    AstronautBox( 7.2f,-17,0,0.7f,2,2,0xf28a32);

    // Detale skafandra.
    AstronautBox(-6,7,3,0.8f,1.4f,0.6f,0xf28a32);
    AstronautBox( 6,7,3,0.8f,1.4f,0.6f,0xf28a32);
    AstronautBox(-2,10,3,0.7f,1.5f,0.6f,0x505b64);
    AstronautBox( 2,10,3,0.7f,1.5f,0.6f,0x505b64);
    AstronautBox(0,7,3,1.3f,0.6f,0.6f,0xf28a32);

    astronaut_initialized=1;
    }

    void DrawAstronaut3DPos(Position *p,float scale)
    {
    AstronautBuild();

    for(int i=0;i<astronaut_triangle_count;i++)
    {
    float3 va=astronaut_v[astronaut_tri[i][0]];
    float3 vb=astronaut_v[astronaut_tri[i][1]];
    float3 vc=astronaut_v[astronaut_tri[i][2]];

    float3 a=f3((*p).pos.x+(va.x*(*p).right.x+va.y*(*p).down.x+va.z*(*p).dir.x)*scale,

    (*p).pos.y+(va.x*(*p).right.y+va.y*(*p).down.y+va.z*(*p).dir.y)*scale,

    (*p).pos.z+(va.x*(*p).right.z+va.y*(*p).down.z+va.z*(*p).dir.z)*scale);

    float3 b=f3((*p).pos.x+(vb.x*(*p).right.x+vb.y*(*p).down.x+vb.z*(*p).dir.x)*scale,

    (*p).pos.y+(vb.x*(*p).right.y+vb.y*(*p).down.y+vb.z*(*p).dir.y)*scale,

    (*p).pos.z+(vb.x*(*p).right.z+vb.y*(*p).down.z+vb.z*(*p).dir.z)*scale);

    float3 c=f3((*p).pos.x+(vc.x*(*p).right.x+vc.y*(*p).down.x+vc.z*(*p).dir.x)*scale,

    (*p).pos.y+(vc.x*(*p).right.y+vc.y*(*p).down.y+vc.z*(*p).dir.y)*scale,

    (*p).pos.z+(vc.x*(*p).right.z+vc.y*(*p).down.z+vc.z*(*p).dir.z)*scale);

    FillDepthTriangle3D(a,b,c,astronaut_color[i]);
    }
    }

    void DrawAstronaut(void)
    {
    static Position p;
    static int initialized=0;

    if(!initialized)
    {
    p.pos=f3(100,0,1700);
    p.right=f3(1,0,0);
    p.down=f3(0,1,0);
    p.dir=f3(0,0,1);
    initialized=1;
    }

    RollIt(&p,0.0005f);
    DrawAstronaut3DPos(&p,1.0f);
    }


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Tue Oct 27 21:03:13 2026
    On 27/10/2026 20:05, Kaz Kylheku wrote:
    On 2026-10-27, Scott Lurndal <scott@slp53.sl.home> wrote:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    That reminds of a joke I have in the TXR Lisp fortune module,
    intended for displaying a random quip at REPL startup.

    Oh, look, I got it after just a couple of tries:

    This is the TXR Lisp interactive listener of TXR 302.
    Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
    (quip)
    "Coding around Unicode grapheme clusters is a character-building exercise."
    (quip)
    "defmicro: error: expansion is larger than original form: switch to defmacro."
    (prinl (quip))
    "This could be the year of the TXR desktop; I can feel it!"
    "This could be the year of the TXR desktop; I can feel it!"
    (put-line (quip))
    TXR kind of supports IEEE 754.00000000000003 floating-point.
    t

    :)

    FP is fine for pricing: look at how ridiculously close to 75.71
    the above approximation is. You just have to make sure never to
    let enough error accumulate so that an intermediate value
    is suddenly closer to the wrong penny value than the right one.
    (Actually you don't even want to get anywhere near that level
    of error.)

    I've used floats for pricing, I think even 32-bit ones. It should work
    fine within certain levels of magnitude - you want a few spare bits of precision beyond individual cents.

    (To clarify, 32 bits may have been used to store prices in a stock file
    for example, so typical magnitudes would have been small, but
    calculations and totals would have used 64 bits.)

    But apart from doing the rounding right as you suggest, the display
    should be only showing 2 decimals when displaying dollars, not 14. That example is very sloppy.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Oct 27 14:18:27 2026
    On 10/27/2026 1:57 PM, fir wrote:
    fir pisze:
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the >>>>>> and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it >>>>>> give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies >>>>>> some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes code >>>>> easier to read.˙ The difference between 0.1 and 0.1f with their binary >>>>> representations is a another matter.

    #include <stdio.h>

    int main(void)
    {
    ˙˙˙˙ double d;
    ˙˙˙˙ d = 0.1f; printf("%.13a\n", d);
    ˙˙˙˙ d = 0.1; printf("%.13a\n", d);
    ˙˙˙˙ return (0);
    }

    % cc -o z t.c && ./z 0x1.99999a0000000p-4 0x1.999999999999ap-4

    The real number is 0.1 is not exactly representable in a binary
    floating point format.˙ See

    https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html

    ˙˙˙ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ˙˙˙ Here is your answer.

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in code >>>> not doubles, and the code is a bit time critical like rasterisation
    goes
    on floats)˙ why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with
    the propagation of floating point errors, the only answer that one can
    give for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a
    float type.˙ Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double


    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive

    (i some cases ai not quite tells the truth and i cant easily validate it)

    it also not gives stright answe if pushed - it says more liek id
    depends on flags, compiler may or may

    so this is no good answer

    (and i asume there may be soem simple answer here i dont know
    (and i suspect its rather - no it will generate float no silly
    conversions

    if no that would be bad)


    ai is besides obviously great - it just drawed me even a small cosmonaut right now

    https://www.youtube.com/watch?v=aZ1F4soMRHE


    its code is not even long
    Let me ponder a guess... You have no idea how/why it works?

    [...]

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Tue Oct 27 17:43:08 2026
    On 2026-10-27 13:45, Steven G. Kargl wrote:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.
    The number 0.1 cannot be represented exactly in binary.

    The C constant "0.1" implicitly has a double value. It has "either the
    nearest representable value" to exactly 0.1, "or the larger or smaller representable value immediately adjacent to the nearest representable
    value, chosen in an implementation-defined
    manner." (6.5.4.3p4). Since it's double precision constant,
    "representable" means "representable as a double precision number".

    0.1f, on the other hand, is explicitly a float value. It follows the
    same rules, but with "representable" meaning "can be represented as a
    float".

    0.1 and 0.1f will therefore not be the same. If you convert 0.1f to
    double precision, it will convert the floating point value actually
    stored to double precision, not the real value it represents. "if the
    value being converted can be represented exactly in the new type, it is unchanged." (6.2.4p4) Any float value is normally representable exactly
    as a double, simply by setting all of the bits that are not stored in
    float format to 0 in double format. Those bits will therefore not have
    the same value they would have in "0.1".

    If you convert 0.1 to float, y, "... the value being converted is in the
    range of values that can be represented but cannot be represented
    exactly," so "the result is either the nearest higher or nearest lower representable value, chosen in an implementation-defined manner."
    (6.3.2.5p2).
    Note that "nearest" is, in this case, being determined relative to the
    floating point value represented by "0.1", not the mathematical value of
    1/10. Also, the "implementation-defined manner" need not be the same as
    the one used for determining the value of floating point constants.

    So, 0.1 and 0.1f have different values, and might be even more different
    after either one is converted to the other's type for comparison. The difference is only in the last representable bits, which won't matter
    for most practical purposes, but will matter if you're comparing for
    exact equality.

    You should use 0.1 when the value will be stored in a double or would
    otherwise immediately get converted to double when used (which is often
    the case). You should use 0.1f to initialize a float variable or to pass
    an argument to a function whose prototype specifies that the
    corresponding parameter has the type float.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Tue Oct 27 18:00:47 2026
    On 2026-10-27 15:54, Steven G. Kargl wrote:
    On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    (snip)

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? like things get slower in runtime? (assuming i use floats in
    code not doubles, and the code is a bit time critical like
    rasterisation goes on floats) why the ai so maniacally puts that f?

    Without seeing code and not knowing whether you are concerned with the
    propagation of floating point errors, the only answer that one can give
    for your first two questions is "yes, no, maybe".

    AI is likely appending the f because you instructed AI to use a float
    type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of double

    float x=a*1.5;

    it also says in such above case the multiplication would be in double
    then converted to float - bout for me its hard to belive

    The standard requires that "The usual arithmetic conversions are
    performed on the operands." (6.5.6p4). Those conversions are described
    in (6.3.2.8), and require that, in a*1.5, the value of a must be
    converted to a double, and that the multiplication be carried out using
    double arithmetic. However, no conversion is required for a*1.5f, and
    the multiplication is carried out using float arithmetic. How the multiplication is carried out is determined without regard to what type
    the result will be stored in. This means that the value of a*1.5 will
    have to be converted back to float before storing it in x, while a value
    of a*1.5f has no such conversion.


    I do not know where to begin to address the above. Perhaps,
    find a copy of K&R to read.
    What K&R said about the matter is far less precise, and in parts,
    obsolete. in particular, float values were always automatically
    converted to double for purposes of calculations.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Tue Oct 27 18:06:25 2026
    On 2026-10-27 17:43, James Kuyper wrote:
    So, 0.1 and 0.1f have different values, and might be even more
    different
    after either one is converted to the other's type for comparison. The difference is only in the last representable bits, which won't matter
    for most practical purposes, but will matter if you're comparing for
    exact equality.

    That was a mistake. The difference involves the last representable bits
    of the float value, and all of the smaller bits in the double format. As
    a practical matter, if float arithmetic is adequate for your
    application, it won't make much difference. However, if you need double precision, you shouldn't be using the "f" suffix.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Tue Oct 27 22:15:28 2026
    On Tue, 27 Oct 2026 18:00:47 -0400, James Kuyper wrote:

    On 2026-10-27 15:54, Steven G. Kargl wrote:


    I do not know where to begin to address the above. Perhaps,
    find a copy of K&R to read.
    What K&R said about the matter is far less precise, and in parts,
    obsolete. in particular, float values were always automatically
    converted to double for purposes of calculations.

    Yes, I know. I suppose I could have pointing to
    N3220.pdf (working draft of C23 I have sitting around),
    but I assumed that would have fallen on blinded
    eyes.

    PS: K&R is still one of my favorite books for learning
    a programming language; even if it is somewhat dated.

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tue Oct 27 15:41:33 2026
    Kaz Kylheku <046-301-5902@kylheku.com> writes:
    On 2026-10-27, Scott Lurndal <scott@slp53.sl.home> wrote:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    [...]

    FP is fine for pricing: look at how ridiculously close to 75.71
    the above approximation is. You just have to make sure never to
    let enough error accumulate so that an intermediate value
    is suddenly closer to the wrong penny value than the right one.

    And how do you do that?

    (Actually you don't even want to get anywhere near that level
    of error.)

    An arbitrarily small error can result in an ambiguity. If you
    calculate a result that should, mathematically, be very close to
    75.715, it could round either to 75.71 or to 75.72.

    I presume there are financial regulations that specify exactly how
    these calculations are to be performed. I have no idea what those
    regulations say, but anyone writing financial code had better know
    about the requirements and implement them correctly.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tue Oct 27 15:53:17 2026
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    The C constant "0.1" implicitly has a double value. It has "either the nearest representable value" to exactly 0.1, "or the larger or smaller representable value immediately adjacent to the nearest representable
    value, chosen in an implementation-defined
    manner." (6.5.4.3p4). Since it's double precision constant,
    "representable" means "representable as a double precision number".

    I think you gave the wrong subsection number, and you didn't specify
    which version of the standard you're quoting from. 6.5.4.3 is
    "Unary arithmetic operators" in the current standard, though it
    may be different in different editions. The wording you quoted
    is from 6.4.4.3p4 in N3220 (C23).

    (I'd like the C standard to adopt named subsections, as used in
    the C++ standard.)

    [...]

    You should use 0.1 when the value will be stored in a double or would otherwise immediately get converted to double when used (which is often
    the case). You should use 0.1f to initialize a float variable or to pass
    an argument to a function whose prototype specifies that the
    corresponding parameter has the type float.

    Using 0.1 in a context where it will be converted to float is likely
    to be harmless. Converting 0.1 to float is likely to yield the same
    value as 0.1f. That's probably not guaranteed, but if there is a
    difference it's probably insignificant.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Wed Oct 28 00:49:19 2026
    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.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tue Oct 27 18:23:43 2026
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    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.

    If you're working with values of type float, the "f" suffix is more
    explicit.

    Logically, something like

    float f = 0.1;

    implies a conversion from double to float, which could be non-trivial.
    In practice, the conversion is likely to be done at compile time.
    The result is *probably* the same as `float f = 0.1f;`, but I don't
    think that's guaranteed.

    I can't think of a case were writing 0.1f rather than 0.1 would
    cause any real (ahem) problems, but there are plenty of cases where
    someone might consider it stylistically better.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Tue Oct 27 21:41:10 2026
    On 2026-10-27 20: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.

    I've used systems where float was significantly faster than double, I
    wouldn't be surprised if someone claimed that this no longer the case on
    any modern machine, but I would be surprised if they had done a
    sufficiently careful search to justify being certain about that.

    I've seen applications where the lower precision of float was
    acceptable, and the extra speed of float was essential to meeting speed requirements.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Wed Oct 28 01:50:16 2026
    On Wed, 28 Oct 2026 00:49:19 -0000 (UTC), 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.

    % cat j8.c
    float
    foo(int n, float *x)
    {
    float s = 0;
    for (int i = 0; i < n; ++i) {
    s += x[i] * 0.1;
    }
    return (s);
    }

    % cc -o z.s -O3 -S j8.c && grep cvts z.s
    cvtss2sd %xmm2, %xmm2
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm2, %xmm0
    cvtss2sd %xmm3, %xmm2
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm2, %xmm0
    cvtss2sd %xmm0, %xmm1
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm0, %xmm0

    That's a lot of useless conversion if 0.1f would have been
    good enough. Change 0.1 to 0.1f in the above code.

    % cc -o z.s -O3 -S j8.c && grep cvts z.s | wc -l
    0

    HTH

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Tue Oct 27 21:55:28 2026
    On 2026-10-27 18:53, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    The C constant "0.1" implicitly has a double value. It has "either the
    nearest representable value" to exactly 0.1, "or the larger or smaller
    representable value immediately adjacent to the nearest representable
    value, chosen in an implementation-defined
    manner." (6.5.4.3p4). Since it's double precision constant,
    "representable" means "representable as a double precision number".

    I think you gave the wrong subsection number, ...
    Yes, that should have been 6.4.5.3p4.

    ... and you didn't specify
    which version of the standard you're quoting from.

    The latest working draft I have access to, n3685.pdf, C202y. It refers
    to C23, and to dates as late as August 2025, using the past tense.

    You should use 0.1 when the value will be stored in a double or would
    otherwise immediately get converted to double when used (which is often
    the case). You should use 0.1f to initialize a float variable or to pass
    an argument to a function whose prototype specifies that the
    corresponding parameter has the type float.

    Using 0.1 in a context where it will be converted to float is likely
    to be harmless. Converting 0.1 to float is likely to yield the same
    value as 0.1f. That's probably not guaranteed, but if there is a
    difference it's probably insignificant.
    Using 0.1f because you don't realize that you actually need double
    precision could be problematic. This thread was started by fir - I
    wouldn't rule out such a possibility.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tue Oct 27 19:02:12 2026
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    On 2026-10-27 18:53, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    The C constant "0.1" implicitly has a double value. It has "either the
    nearest representable value" to exactly 0.1, "or the larger or smaller
    representable value immediately adjacent to the nearest representable
    value, chosen in an implementation-defined
    manner." (6.5.4.3p4). Since it's double precision constant,
    "representable" means "representable as a double precision number".

    I think you gave the wrong subsection number, ...
    Yes, that should have been 6.4.5.3p4.

    ... and you didn't specify
    which version of the standard you're quoting from.

    The latest working draft I have access to, n3685.pdf, C202y. It refers
    to C23, and to dates as late as August 2025, using the past tense.

    The draft closest to the C23 standard is N3220.

    The latest C2y draft is N3998, just released a few days ago.

    https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3998.pdf

    [...]
    Using 0.1 in a context where it will be converted to float is likely
    to be harmless. Converting 0.1 to float is likely to yield the same
    value as 0.1f. That's probably not guaranteed, but if there is a
    difference it's probably insignificant.

    Using 0.1f because you don't realize that you actually need double
    precision could be problematic. This thread was started by fir - I
    wouldn't rule out such a possibility.

    Sure -- but I did specify "where it will be converted to float".

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From steve g@3:633/10 to All on Wed Oct 28 02:11:58 2026
    fir <profesor.fir@gmail.com> writes:


    but the question is: can using .1 instead of 0.1f make me any harm in code? like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes on floats) why the ai so maniacally puts that f?

    dunno, the Gnu Libc has many options for floats/doubles. You can use a
    prefix of `-' and such. check gnu libc manual on google.

    i gues the answer is NOT but maybe soem can show at least one case it could be
    worse?

    12.12.10 Parsing a Template String
    ----------------------------------

    GNU Libc --- have fun...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From steve g@3:633/10 to All on Wed Oct 28 02:19:24 2026
    fir <profesor.fir@gmail.com> writes:


    float x=a*1.5;

    it also says in such above case the multiplication would be in double then converted to float - bout for me its hard to belive

    you could use ratios.

    (i some cases ai not quite tells the truth and i cant easily validate it)

    Hahha... TMS?

    it also not gives stright answe if pushed - it says more liek id depends on flags, compiler may or may

    so this is no good answer

    Welcome to programming :)

    (and i asume there may be soem simple answer here i dont know
    (and i suspect its rather - no it will generate float no silly conversions

    Unlikely.

    if no that would be bad)

    Try lisp, you can use fractions, ratios, very large doubles. It is
    somewhat slow with floating point usually. Ratios I like. 1/100 - that
    is it.

    If you want real speed with numbers I would look into fortran (actually
    I would not).

    (numerator (/ 1 100)) => 1
    (denominator (/ 1 100) => 100


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From steve g@3:633/10 to All on Wed Oct 28 02:20:27 2026
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:


    Oh, but the ai is his nest of books. Almost like the tommyknockers from Stephen King. The residents of Haven started making things that they did not understand at all.

    Thank you!

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Tue Oct 27 23:21:39 2026
    steve g <Sgonedes1977@gmail.com> writes:
    fir <profesor.fir@gmail.com> writes:
    but the question is: can using .1 instead of 0.1f make me any harm in code? >> like things get slower in runtime? (assuming i use floats in code
    not doubles, and the code is a bit time critical like rasterisation goes on >> floats) why the ai so maniacally puts that f?

    dunno, the Gnu Libc has many options for floats/doubles. You can use a
    prefix of `-' and such. check gnu libc manual on google.

    fir was asking about a C language issue, nothing to do with GNU libc or
    any other implementation of the C standard library.

    What on Earth does "prefix of `-'" refer to?

    i gues the answer is NOT but maybe soem can show at least one case it could be
    worse?

    12.12.10 Parsing a Template String
    ----------------------------------

    GNU Libc --- have fun...

    That has nothing to do with the question, which was about 0.1 vs. 0.1f
    in C source code. And that question has already been discussed at some
    length.

    I don't want to discourage you from posting, but maybe you should
    concentrate on asking questions rather than trying to answer them.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From steve g@3:633/10 to All on Wed Oct 28 02:25:11 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    Try asking them for (ceiling 75.71000000000001)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed Oct 28 07:32:14 2026
    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 00:49:19 -0000 (UTC), 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.

    % cat j8.c
    float
    foo(int n, float *x)
    {
    float s = 0;
    for (int i = 0; i < n; ++i) {
    s += x[i] * 0.1;
    }
    return (s);
    }

    % cc -o z.s -O3 -S j8.c && grep cvts z.s
    cvtss2sd %xmm2, %xmm2
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm2, %xmm0
    cvtss2sd %xmm3, %xmm2
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm2, %xmm0
    cvtss2sd %xmm0, %xmm1
    cvtss2sd %xmm0, %xmm0
    cvtsd2ss %xmm0, %xmm0

    That's a lot of useless conversion if 0.1f would have been
    good enough. Change 0.1 to 0.1f in the above code.

    % cc -o z.s -O3 -S j8.c && grep cvts z.s | wc -l
    0

    HTH


    if so its totally terrible, i was kinda not aware of that


    i would say its wrong and stupid probably becouse in float computations
    such numbers should be floats imo in doubles it should be doubles


    i should run my own test but im too exhausted


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed Oct 28 07:51:13 2026
    fir pisze:
    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 00:49:19 -0000 (UTC), 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.

    % cat j8.c
    float
    foo(int n, float *x)
    {
    ˙˙˙ float s = 0;
    ˙˙˙ for (int i = 0; i < n; ++i) {
    ˙˙˙˙˙˙ s += x[i] * 0.1;
    ˙˙˙ }
    ˙˙˙ return (s);
    }

    % cc -o z.s -O3 -S j8.c && grep cvts z.s
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm2, %xmm2
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm2, %xmm0
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm3, %xmm2
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm2, %xmm0
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm1
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm0, %xmm0

    That's a lot of useless conversion if 0.1f would have been
    good enough.˙ Change 0.1 to 0.1f in the above code.

    % cc -o z.s -O3 -S j8.c && grep cvts z.s | wc -l
    ˙˙˙˙˙˙˙ 0

    HTH


    if so its totally terrible, i was kinda not aware of that


    i would say its wrong and stupid probably becouse in float computations
    such numbers should be floats imo in doubles it should be doubles


    i should run my own test but im too exhausted

    maybe no wonder i was not aware of this if this is so stupid it no come
    to my mind
    (should i also write 0.0f insetad of 0 BTW?)

    as to optimistation there is probably a flag wjich turns it off 0 i mean replace .1 as doube as .1 as floats when it can help to remove this conversions

    but im not sure which one in gcc probably -ffast-math

    but i not tested/talked yet

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed Oct 28 07:55:11 2026
    fir pisze:
    fir pisze:
    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 00:49:19 -0000 (UTC), 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.

    % cat j8.c
    float
    foo(int n, float *x)
    {
    ˙˙˙ float s = 0;
    ˙˙˙ for (int i = 0; i < n; ++i) {
    ˙˙˙˙˙˙ s += x[i] * 0.1;
    ˙˙˙ }
    ˙˙˙ return (s);
    }

    % cc -o z.s -O3 -S j8.c && grep cvts z.s
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm2, %xmm2
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm2, %xmm0
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm3, %xmm2
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm2, %xmm0
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm1
    ˙˙˙˙˙˙˙˙ cvtss2sd˙˙˙˙˙˙˙ %xmm0, %xmm0
    ˙˙˙˙˙˙˙˙ cvtsd2ss˙˙˙˙˙˙˙ %xmm0, %xmm0

    That's a lot of useless conversion if 0.1f would have been
    good enough.˙ Change 0.1 to 0.1f in the above code.

    % cc -o z.s -O3 -S j8.c && grep cvts z.s | wc -l
    ˙˙˙˙˙˙˙ 0

    HTH


    if so its totally terrible, i was kinda not aware of that


    i would say its wrong and stupid probably becouse in float
    computations such numbers should be floats imo in doubles it should be
    doubles


    i should run my own test but im too exhausted

    maybe no wonder i was not aware of this if this is so stupid it no come
    to my mind
    (should i also write 0.0f insetad of 0 BTW?)

    as to optimistation there is probably a flag wjich turns it off 0 i mean replace .1 as doube as .1 as floats when it can help to remove this conversions

    but im not sure which one in gcc probably -ffast-math

    but i not tested/talked yet
    ai says even fast math not enebles that but there is a flag


    -fsingle-precision-constant.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Wed Oct 28 08:39:23 2026
    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.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Wed Oct 28 08:45:55 2026
    On 28/10/2026 02:41, James Kuyper wrote:
    On 2026-10-27 20: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.

    I've used systems where float was significantly faster than double, I wouldn't be surprised if someone claimed that this no longer the case on
    any modern machine, but I would be surprised if they had done a
    sufficiently careful search to justify being certain about that.


    If they were certain about it, then they certainly would not have done a careful enough search.

    I've seen applications where the lower precision of float was
    acceptable, and the extra speed of float was essential to meeting speed requirements.

    People use 16-bit and 8-bit floating point formats too. I expect that
    these days, most floating point calculations executed across the world
    are 8 bit.

    Once you have enough precision that your calculations are accurate
    enough for your required application, there's little point in using
    bigger formats - especially if speed is relevant.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Wed Oct 28 08:56:12 2026
    On 27/10/2026 23:53, Keith Thompson wrote:
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:
    [...]
    The C constant "0.1" implicitly has a double value. It has "either the
    nearest representable value" to exactly 0.1, "or the larger or smaller
    representable value immediately adjacent to the nearest representable
    value, chosen in an implementation-defined
    manner." (6.5.4.3p4). Since it's double precision constant,
    "representable" means "representable as a double precision number".

    I think you gave the wrong subsection number, and you didn't specify
    which version of the standard you're quoting from. 6.5.4.3 is
    "Unary arithmetic operators" in the current standard, though it
    may be different in different editions. The wording you quoted
    is from 6.4.4.3p4 in N3220 (C23).

    (I'd like the C standard to adopt named subsections, as used in
    the C++ standard.)


    Section numbering in the C standards was fine until C23 - from C90 to
    C17, almost all changes added new numbered sections without changing the existing ones. But C23 had too many changes, and some things were
    renumbered. So I /was/ happy with numbered, rather than named,
    sections. Going forward, however, I agree with you - named subsections
    seem the best choice for consistent references.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Oct 28 06:54:12 2026
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:

    On 2026-10-27 15:54, Steven G. Kargl wrote:
    On Tue, 27 Oct 2026 20:15:20 +0100, fir wrote:
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 18:50:09 +0100, fir wrote:
    Steven G. Kargl pisze:
    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    (snip)

    but the question is: can using .1 instead of 0.1f make me any
    harm in code? like things get slower in runtime? (assuming i
    use floats in code not doubles, and the code is a bit time
    critical like rasterisation goes on floats) why the ai so
    maniacally puts that f?

    Without seeing code and not knowing whether you are concerned
    with the propagation of floating point errors, the only answer
    that one can give for your first two questions is "yes, no,
    maybe".

    AI is likely appending the f because you instructed AI to use a
    float type. Why not ask AI why it appends the f?

    it says: i add f that the number would be float type instead of
    double

    float x=a*1.5;

    it also says in such above case the multiplication would be in
    double then converted to float - bout for me its hard to belive

    The standard requires that "The usual arithmetic conversions are
    performed on the operands." (6.5.6p4). Those conversions are
    described in (6.3.2.8), and require that, in a*1.5, the value of a
    must be converted to a double, and that the multiplication be
    carried out using double arithmetic. However, no conversion is
    required for a*1.5f, and the multiplication is carried out using
    float arithmetic. [...]

    Maybe. IIANM the C standard allows floating operations to be
    carried out in greater precision than the nominal type of the
    expression, and thus a*1.5f might very well be carried out using,
    e.g., the same operations as would be used by double.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From tTh@3:633/10 to All on Wed Oct 28 15:08:54 2026
    On 10/28/26 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.

    Explicit is better than implicit ?

    --
    ** **
    * tTh des Bourtoulots *
    * http://maison.tth.netlib.re/ *
    ** **

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Oct 28 07:49:27 2026
    tTh <tth@none.invalid> writes:

    On 10/28/26 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.

    Explicit is better than implicit ?

    Not always, but in this case there is no "implicit" way. If a
    floating-point constant has an "f" suffix it's of type float, and
    if it doesn't it's of type double. Having a suffix necessarily
    changes the meaning.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Oct 28 08:01:10 2026
    James Kuyper <jameskuyper@alumni.caltech.edu> writes:

    On 2026-10-27 13:45, Steven G. Kargl wrote:

    On Tue, 27 Oct 2026 11:53:55 +0100, fir wrote:

    if ai generates me some functions it puts everywhere this f at the
    and yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may
    it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)

    i doubt it probably it makes difference but im strictly not sure

    The leading zero in 0.1 or 0.1f is irrelevant, but (to me) makes
    code easier to read. The difference between 0.1 and 0.1f with
    their binary representations is a another matter.

    The number 0.1 cannot be represented exactly in binary.

    The C constant "0.1" implicitly has a double value. It has "either
    the nearest representable value" to exactly 0.1, "or the larger or
    smaller representable value immediately adjacent to the nearest
    representable value, chosen in an implementation-defined manner." (6.5.4.3p4). Since it's double precision constant, "representable"
    means "representable as a double precision number".

    0.1f, on the other hand, is explicitly a float value. It follows
    the same rules, but with "representable" meaning "can be represented
    as a float".

    Yes, except implementations are allowed to represent floating-point
    constants using a greater range and precision than the nominal type
    would imply. So 0.1 and 0.1f could have the same value.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Wed Oct 28 16:38:50 2026
    On 2026-10-28 02:23, Keith Thompson wrote:
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    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.

    If you're working with values of type float, the "f" suffix is more
    explicit.

    Logically, something like

    float f = 0.1;

    implies a conversion from double to float, which could be non-trivial.

    I think "logically" is a misleading word here.

    The thought of something "implicit" going on here is a thought that
    might stem from (knowing) the inherent mechanisms and quirks of the
    C-language not necessarily what one would logically expect.

    My expectation (for sensibly defined programming languages) would be
    that literals for two different "real numbers" types are generic WRT
    those types; they should be usable [in "C"] without loss (or kludges)
    with 'float' and 'double'.

    In practice, the conversion is likely to be done at compile time.
    The result is *probably* the same as `float f = 0.1f;`, but I don't
    think that's guaranteed.

    I can't think of a case were writing 0.1f rather than 0.1 would
    cause any real (ahem) problems, but there are plenty of cases where
    someone might consider it stylistically better.

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Wed Oct 28 16:22:08 2026
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:

    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Wed Oct 28 16:23:01 2026
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    Kaz Kylheku <046-301-5902@kylheku.com> writes:
    On 2026-10-27, Scott Lurndal <scott@slp53.sl.home> wrote:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    [...]

    FP is fine for pricing: look at how ridiculously close to 75.71
    the above approximation is. You just have to make sure never to
    let enough error accumulate so that an intermediate value
    is suddenly closer to the wrong penny value than the right one.

    And how do you do that?

    (Actually you don't even want to get anywhere near that level
    of error.)

    An arbitrarily small error can result in an ambiguity. If you
    calculate a result that should, mathematically, be very close to
    75.715, it could round either to 75.71 or to 75.72.

    I presume there are financial regulations that specify exactly how
    these calculations are to be performed. I have no idea what those >regulations say, but anyone writing financial code had better know
    about the requirements and implement them correctly.

    There are. And they explicitly forbid using binary floating
    point representations.

    Typically they use scaled fixed point 64-bit integers in modern code.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Wed Oct 28 16:27:21 2026
    On Wed, 28 Oct 2026 07:55:11 +0100, fir wrote:


    but i not tested/talked yet
    ai says even fast math not enebles that but there is a flag


    -fsingle-precision-constant.

    It is a poor decision to depend on any specific compiler's
    options unless you intend to never use any other compiler.
    With clang, I see

    % cc -o z.s -S -O3 -fsingle-precision-constant j8.c
    cc: warning: optimization flag '-fsingle-precision-constant' is not
    supported [-Wignored-optimization-argument]

    HTH

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Wed Oct 28 17:44:33 2026
    On 28/10/2026 17:27, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 07:55:11 +0100, fir wrote:


    but i not tested/talked yet
    ai says even fast math not enebles that but there is a flag


    -fsingle-precision-constant.

    It is a poor decision to depend on any specific compiler's
    options unless you intend to never use any other compiler.

    It is fine to do so in non-portable code. Most of my work is
    specifically targeting gcc, and if the code is better (clearer, safer to maintain, more efficient) as a result of compiler-specific flags or compiler-specific extensions, that's fine. Of course, if the same
    results can be achieved without non-portable flags or extensions, that
    is better.

    The key use of flags like this is for microcontrollers with hardware
    support for single-precision floating point, but not for double
    precision - which then needs to be handled by software routines. The
    use of "-fsingle-precision-constant" is primarily for handling
    third-party code or other code that you don't want to change, but where
    you want to use single precision as much as possible. For your own code
    on such devices, you would use "f" suffixes.

    The "-Wdouble-promotion" flag is also very useful here - it will let you
    know if you have accidentally promoted a float (such as by using a double-precision constant in an expression).


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed Oct 28 19:15:45 2026
    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:

    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    there is something like integer*float multiplication , or not?
    if so 25*a and 25.*a or 25.0f*a could make a difference

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed Oct 28 19:47:56 2026
    fir pisze:
    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:

    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed.˙ No.˙ IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer.˙ It's easier to read.

    float foo(float a) {
    ˙˙ float x = 25 * a;
    ˙˙ return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    there is something like integer*float multiplication , or not?
    if so 25*a and 25.*a or 25.0f*a could make a difference

    and i would say it is good to be able to express what one wants

    and write 25*a, 25.0d *a, 25.0f *a //if there would be version for double

    but for me its really weird that compiler cant 25.*a resolve as floats
    if optimisation is on and put those conversions

    same as 25 imo shouldn be treated as int if in runtime faster it would
    be if that would be short long or char

    imo constant is constant so 25.1 imo even should not represent nor float
    nor double but probably the 'ideal' value




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Wed Oct 28 19:10:37 2026
    On Wed, 28 Oct 2026 19:15:45 +0100, fir wrote:

    Steven G. Kargl pisze:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:

    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    there is something like integer*float multiplication , or not?
    if so 25*a and 25.*a or 25.0f*a could make a difference

    For 25, 25., and 25.0f, the compiler ought to produce the
    same assembly. Why? Because the integer 25 is exactly
    representable in both float (IEEE-754 binary32) and double
    (IEEE-754 binary64), and the float 25.0f is exactly
    representable in double. A compiler can take advantage of
    this to produce an optimal assembly listing. At least with
    clang, one sees this.

    float
    foo(int n, float x)
    {
    // float a = x * 25;
    // float a = x * 25.f;
    float a = x * 25.;
    return (a);
    }

    Selecting each declaration in order yields

    % cc -o z.s -S -O3 j8.c && md5 -r z.s
    0879b3f8c5924476e64657d4b17a9405 z.s
    % cc -o z.s -S -O3 j8.c && md5 -r z.s
    0879b3f8c5924476e64657d4b17a9405 z.s
    % cc -o z.s -S -O3 j8.c && md5 -r z.s
    0879b3f8c5924476e64657d4b17a9405 z.s

    Now, take x/10, x*0.1, and x*0.1f.

    float
    foo(int n, float x)
    {
    // float a = x * 0.1;
    // float a = x * 0.1f;
    float a = x / 10;
    return (a);
    }

    The integer 10 is exactly representable, but a compiler will
    likely produce a division, and that's what we see with clang

    .LCPI0_0:
    .long 0x41200000 # float 10
    ...
    .cfi_def_cfa_register %rbp
    divss .LCPI0_0(%rip), %xmm0
    popq %rbp
    .cfi_def_cfa %rsp, 8
    retq

    The real number 0.1 is not exactly representable in either
    float or double. The compiler will chose the best available
    floating point number nearest to 0.1 and 0.1f (and this
    depends on the rounding mode). With 0.1f and clang, you get

    .LCPI0_0:
    .long 0x3dcccccd # float 0.100000001
    ...
    .cfi_def_cfa_register %rbp
    mulss .LCPI0_0(%rip), %xmm0
    popq %rbp
    .cfi_def_cfa %rsp, 8
    retq

    Finally, with 0.1, clang produces

    .LCPI0_0:
    .quad 0x3fb999999999999a # double 0.10000000000000001 ...

    .cfi_def_cfa_register %rbp
    cvtss2sd %xmm0, %xmm0
    mulsd .LCPI0_0(%rip), %xmm0
    cvtsd2ss %xmm0, %xmm0
    popq %rbp
    .cfi_def_cfa %rsp, 8
    retq

    Notice, the conversions in this case. If numerical accuracy
    is unimportant but speed is, then using 0.1f seems to be the
    best choice. If numerical accuracy is important, one probably
    use double from the get-go.

    If you are going to work with floating point arithmetic,
    then you should read Goldberg's paper. In fact, you
    will likely want to read it multiple times.

    --
    steve


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Wed Oct 28 22:25:04 2026
    On Wed, 28 Oct 2026 08:39:23 +0100
    David Brown <david.brown@hesbynett.no> 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? s
    uffix?

    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.



    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.





    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 13:27:33 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-10-28 02:23, Keith Thompson wrote:
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    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.
    If you're working with values of type float, the "f" suffix is more
    explicit.
    Logically, something like
    float f = 0.1;
    implies a conversion from double to float, which could be
    non-trivial.

    I think "logically" is a misleading word here.

    Perhaps "in the abstract machine" would have been clearer than
    "logically".

    In the abstract machine, 0.1 is of type double. The initialization
    causes that value to be converted from double to float.

    The thought of something "implicit" going on here is a thought that
    might stem from (knowing) the inherent mechanisms and quirks of the C-language not necessarily what one would logically expect.

    My logical expectation is based on knowing C.

    My expectation (for sensibly defined programming languages) would be
    that literals for two different "real numbers" types are generic WRT
    those types; they should be usable [in "C"] without loss (or kludges)
    with 'float' and 'double'.

    Sure, a compiler can generate code to store (float)0.1 in f without
    doing a conversion, as long as the semantics are consistent. But 0.1f
    and 0.1 are of different types. If they happen to behave the same way
    in some context, it's a consequence of the C language rules.

    Note in particular that this:
    double d = 0.1f;
    has different semantics than
    double d = 0.1;
    if double has more precision than float.

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 13:31:06 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:
    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    I disagree. Yes, the int constant 25 is implicitly converted to float
    as part of the "usual arithmetic conversions". But I find
    float x = 25.0 * a;
    or even
    float x = 25.0f * a;
    clearer than
    float x = 25 * a;

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 14:26:05 2026
    David Brown <david.brown@hesbynett.no> writes:
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Oct 28 14:34:30 2026
    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.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Oct 28 14:36:53 2026
    On 10/27/2026 5:49 PM, 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.

    Well, say you want the result from a frag shader to be pixel perfect to
    a CPU version of it. Using double on the CPU can cause a headache.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Wed Oct 28 21:54:10 2026
    On Wed, 28 Oct 2026 02:19:24 -0400, steve g wrote:

    Try lisp, you can use fractions, ratios, very large doubles. It is
    somewhat slow with floating point usually. Ratios I like. 1/100 -
    that is it.

    Python has all that. Plus overloads for actual infix operators.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Oct 28 14:58:53 2026
    On 10/28/2026 2:54 PM, Lawrence D?Oliveiro wrote:
    On Wed, 28 Oct 2026 02:19:24 -0400, steve g wrote:

    Try lisp, you can use fractions, ratios, very large doubles. It is
    somewhat slow with floating point usually. Ratios I like. 1/100 -
    that is it.

    Python has all that. Plus overloads for actual infix operators.

    Python is pretty nice when I need to use it. Python 2 or Python 3? ;^)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Thu Oct 29 00:12:56 2026
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

    David Brown <david.brown@hesbynett.no> writes:
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;


    David almost certainly was talking about use of 0.1f in arithmetic
    expressions rather than in simple initialization.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Wed Oct 28 22:33:23 2026
    On 28/10/2026 22:12, Michael S wrote:
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

    David Brown <david.brown@hesbynett.no> writes:
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;


    David almost certainly was talking about use of 0.1f in arithmetic expressions rather than in simple initialization.



    Yeah, intermediate calculations using 64 bits can give a different and
    more precise result even after it has been converted to 32 bits.

    For example this:

    #include <stdio.h>

    int main(void) {
    float a = 0.1f * 0.1f;
    float b = 0.1 * 0.1;

    printf("%20.20f\n", a);
    printf("%20.20f\n", b);
    printf("%20.20f\n", 1 - a * 100);
    printf("%20.20f\n", 1 - b * 100);
    }


    Displays:

    0.01000000070780515671
    0.00999999977648258209
    -0.00000011920928955078
    0.00000000000000000000

    on gcc 9.x on x64.

    It will need the compiler to do the reduction, but DB is likely using a cross-compiler so it is not being done within target device,

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Wed Oct 28 22:44:09 2026
    On Wed, 28 Oct 2026 13:31:06 -0700, Keith Thompson wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:
    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    I disagree. Yes, the int constant 25 is implicitly converted to float
    as part of the "usual arithmetic conversions". But I find
    float x = 25.0 * a;
    or even
    float x = 25.0f * a;
    clearer than
    float x = 25 * a;

    ROTL. You find '25 * a' too difficult to realize
    that it is twenty-five times a. The 2 or 3 extra
    digits (i.e., '.', '0', and 'f') are nothing but
    fluff.

    --
    steve



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 16:05:06 2026
    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;

    David almost certainly was talking about use of 0.1f in arithmetic expressions rather than in simple initialization.

    Agreed -- and I asked him for examples. (And no, didn't mean to
    suggest that there are no such examples.)

    And now that I've thought about it a bit more, here's a possible
    example:

    float f = rand(); // prevent optimization
    f *= 0.1;
    // f *= 0.1f;

    With 0.1, f is promoted to double before being multiplied by 0.1, and
    the result is converted to float. With 0.1f, double is not involved.
    And in the generated x86_64 assembly from gcc, I see cvtss2sd and
    cvtsd2ss when I use 0.1 that don't appear when I use 0.1f.

    Both expressions *might* yield the same result (and do in the small
    handful of cases I've checked), but it would take more analysis
    than I'm willing to perform to prove it in all cases.

    I was too quick to assume that if a compiler sees 0.1 in an expression involving float operands, it can safely treat it as 0.1f. Since 0.1
    causes the usual arithmetic conversions to convert the other operand
    from float to double, I was very probably wrong.

    I can still imagine a compiler optimizing `f *= 0.1;` to use
    float arithmetic. I wonder if there are more clear-cut examples.

    I'm assuming that FLT_EVAL_METHOD==0, meaning that float expressions
    are evaluated as float. If FLT_EVAL_METHOD==1, float expressions
    are evaluated to the range and precision of type double.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 00:08:28 2026
    On 2026-10-28 21:27, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    The thought of something "implicit" going on here is a thought that
    might stem from (knowing) the inherent mechanisms and quirks of the
    C-language not necessarily what one would logically expect.

    My logical expectation is based on knowing C.

    And knowing also a lot of the internals, and C-standards documents,
    I'm sure. (My point was just that "normal" C-programmers might not
    have that background and would "logically" assume different. - But
    since you had clarified the word by using a more appropriate one in
    this post I'm fine with that now. Thanks.)


    My expectation (for sensibly defined programming languages) would be
    that literals for two different "real numbers" types are generic WRT
    those types; they should be usable [in "C"] without loss (or kludges)
    with 'float' and 'double'.

    Sure, a compiler can generate code to store (float)0.1 in f without
    doing a conversion, as long as the semantics are consistent.

    Only that my view here is that you need a "conversion" in both cases,
    since you primarily have to convert from a string representation of
    the literal to the appropriate internal (binary) form. And given the
    _program contexts_ you can do _the one_ appropriate conversion for
    the types involved (i.e. Text->Float and Text->Double, respectively).

    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    (And, ideally, practically relevant usages. - We know that "C" is as
    it is, and as it is there's some unavoidable consequences from that.)

    But 0.1f
    and 0.1 are of different types. If they happen to behave the same way
    in some context, it's a consequence of the C language rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!


    Note in particular that this:
    double d = 0.1f;
    has different semantics than
    double d = 0.1;
    if double has more precision than float.

    Sure. But isn't that difference basically just a home-brewed C-issue?

    I'd be curious why one would write the former in the first place.
    Will a programmer or program designer gain something by assigning a
    'float' constant literal to a 'double' variable?

    I've never needed such, erm.., "hacks" ever in any of my C-code or
    in other languages. So I'm honestly asking.

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 00:27:56 2026
    On 2026-10-28 23:44, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 13:31:06 -0700, Keith Thompson wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    [...]

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    I disagree. Yes, the int constant 25 is implicitly converted to float
    as part of the "usual arithmetic conversions". But I find
    float x = 25.0 * a;
    or even
    float x = 25.0f * a;
    clearer than
    float x = 25 * a;

    ROTL. You find '25 * a' too difficult to realize
    that it is twenty-five times a. The 2 or 3 extra
    digits (i.e., '.', '0', and 'f') are nothing but
    fluff.

    I basically agree with Keith here.

    It's not about "realizing" the _mathematical_ meaning of "25 * a",
    or about having a clearer/terser (less "fluffy") expression.

    I'm sure the compiler would be able to create the correct internal representation based on the program context; in that respect the
    "25" should suffice, and not even impose any additional conversion
    operation. IMO. (There might be some hindrance based on C's design
    that I'm not aware of, though.)

    From a programmers' perspective it always appeared useful to see
    the type of the involved components in expressions. That's way I
    write in every language "25.0" if I want to express a Real value.
    (In some language it can even be functionally important, or even
    be mandated.)

    Where I disagree is that the 'f' would be meaningful as "concept"
    (even if in "C" there's two "sorts" of floats, and two literals
    for the same abstract numeric domain of real numbers). (But see
    my disclaimer above about possible home-brewed hindrances in "C".)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 16:39:00 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 13:31:06 -0700, Keith Thompson wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 07:51:13 +0100, fir wrote:
    (should i also write 0.0f insetad of 0 BTW?)

    A lot of context removed. No. IMO, if you have
    a numerical constant that can be written as an
    integer and that integer is less than 2^P
    where P is the precision of the floating point
    type of interest (here, 2^P means 2 raised to
    the Pth power), then simply write the numerical
    constant as an integer. It's easier to read.

    float foo(float a) {
    float x = 25 * a;
    return (x);
    }

    A compiler ought to convert 25 in the above to
    25.f as 25 is exactly representable (at least in
    IEEE-754 binary32 format) in float.

    I disagree. Yes, the int constant 25 is implicitly converted to float
    as part of the "usual arithmetic conversions". But I find
    float x = 25.0 * a;
    or even
    float x = 25.0f * a;
    clearer than
    float x = 25 * a;

    ROTL. You find '25 * a' too difficult to realize
    that it is twenty-five times a. The 2 or 3 extra
    digits (i.e., '.', '0', and 'f') are nothing but
    fluff.

    I didn't say that I find `25 * a` difficult to understand. I said
    that I find `25.0 * a` clearer. Even if it's only very slightly
    easier to understand, that's well worth the cost of typing two
    extra characters.

    In this particular case, the type "float" appears on the same line as
    the constant. In other cases, you might have an isolated assignment
    like `x = 25.0 * a;`. In such a case, I find the floating-point
    constant helpful as a reminder that this is a floating-point
    operation, not an integer operation.

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed Oct 28 16:56:45 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-10-28 21:27, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    The thought of something "implicit" going on here is a thought that
    might stem from (knowing) the inherent mechanisms and quirks of the
    C-language not necessarily what one would logically expect.
    My logical expectation is based on knowing C.

    And knowing also a lot of the internals, and C-standards documents,
    I'm sure. (My point was just that "normal" C-programmers might not
    have that background and would "logically" assume different. - But
    since you had clarified the word by using a more appropriate one in
    this post I'm fine with that now. Thanks.)

    My expectation (for sensibly defined programming languages) would be
    that literals for two different "real numbers" types are generic WRT
    those types; they should be usable [in "C"] without loss (or kludges)
    with 'float' and 'double'.
    Sure, a compiler can generate code to store (float)0.1 in f without
    doing a conversion, as long as the semantics are consistent.

    Only that my view here is that you need a "conversion" in both cases,
    since you primarily have to convert from a string representation of
    the literal to the appropriate internal (binary) form. And given the
    _program contexts_ you can do _the one_ appropriate conversion for
    the types involved (i.e. Text->Float and Text->Double, respectively).

    I don't think of the process that takes a source code construct
    like `0.1` and yields a value of 0.1 at run time as a "conversion".
    It's just the meaning of the token. "Text" is not a C type. (The
    constant might happen to be held in a C string at some point, but
    only if the compiler is written in C.)

    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    By 'F', you mean the 'f' or 'F' suffix on a floating constant, right?
    (Your use of upper case threw me off for a moment. No biggie.)

    (And, ideally, practically relevant usages. - We know that "C" is as
    it is, and as it is there's some unavoidable consequences from that.)

    Yes, we know that from "C", which is the topic of this newsgroup.
    I'm not sure what distinction you're making. You seem to be
    implying that C imposes some set of obscure rules on top of what
    all programmers know. 0.0 is something that everyone recognizes,
    while 0.0f is an obscure C feature.

    I don't think of it that way. C code is governed by the rules of C.

    But 0.1f and 0.1 are of different types. If they happen to behave
    the same way in some context, it's a consequence of the C language
    rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!

    In many cases, yes, the final result is likely to be the same.
    Even so, using 0.1 rather than 0.1f can result in less efficient
    generated code if the compiler isn't sufficiently clever, or perhaps
    even if it is.

    And if I'm trying to use type float and avoid type double (as, for
    example, David Brown has good reasons to do), writing `0.1f` is a
    great way to avoid having to think about how clever the compiler
    has to be to avoid unnecessary conversions.

    Note in particular that this:
    double d = 0.1f;
    has different semantics than
    double d = 0.1;
    if double has more precision than float.

    Sure. But isn't that difference basically just a home-brewed C-issue?

    "Home-brewed"? It's a rule imposed by the C language.

    I'd be curious why one would write the former in the first place.
    Will a programmer or program designer gain something by assigning a
    'float' constant literal to a 'double' variable?

    Probably not. The point is that there are real semantic differences
    between 0.1f and 0.1.

    On the other hand, if you want to print a float value using printf, it
    will be converted to double.

    printf("%.55f\n%.55f\n", 0.1f, 0.1);

    0.1000000014901161193847656250000000000000000000000000000
    0.1000000000000000055511151231257827021181583404541015625

    I've never needed such, erm.., "hacks" ever in any of my C-code or
    in other languages. So I'm honestly asking.

    It was an example, not meant to be a demonstration of useful code.
    I could have mentioned that `sizeof 0.1f` is likely to be different
    from `sizeof 0.1`, but that's even more unrealistic.

    I think there's a common attitude that double is the "default" type
    for floating-point constants. That's a valid way to look at it, but
    I suggest an equally valid way is to say that *there is no default*.

    If I write 0.1f, I'm explicitly using type float.
    If I write 0.1, I'm explicitly using type double.
    If I write 0.1L, I'm explicitly using type long double.

    In one of the three cases, the suffix just happens to be empty.

    (And again, I'm glossing over FLT_EVAL_METHOD.)

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Thu Oct 29 00:22:44 2026
    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:


    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    --
    steve



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Wed Oct 28 17:59:19 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros. Otherwise someone might wonder if there had been
    a

    #define return(x) return ...something involving x...


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Thu Oct 29 01:50:10 2026
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    Unlearning is not likely to happen. I've been a long-time
    contributor to FreeBSD, and have no plans to stop. Feel
    free to check the git history on FreeBSD libm sources.
    My finger prints are all over the code. So, yeah, I know
    a enough about floating point arithmetic and C standard
    requirements to be dangerous.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 09:30:02 2026
    On 29/10/2026 00:08, Janis Papanagnou wrote:
    On 2026-10-28 21:27, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]

    But 0.1f
    and 0.1 are of different types.˙ If they happen to behave the same way
    in some context, it's a consequence of the C language rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!


    Do you mean that you think it would have been better if the rules of C
    were different, so that the context always determined how "0.1" was to
    be interpreted? That's not an unreasonable feature for a programming
    language - AFAIUI, that is how numeric literals work in Ada. But it is
    not how things work in C, where the value and type of an expression is determined entirely by the expression itself, independently of the context.

    I hate to try to speculate as to whether the C philosophy or the Ada philosophy here is more common - but I don't know of any languages other
    than Ada that make the type of literals dependent on their use or
    context. There are of course many languages that might follow the Ada
    path, unbeknownst to me. (You can have fun making class types in C++,
    and no doubt other languages, that emulate this behaviour, but it is not
    part of the language.)

    So when you write "float x = 0.1;", the 0.1 is a value of type double.
    It is converted to float by the assignment operator.


    Note in particular that this:
    ˙˙˙˙ double d = 0.1f;
    has different semantics than
    ˙˙˙˙ double d = 0.1;
    if double has more precision than float.

    Sure. But isn't that difference basically just a home-brewed C-issue?

    I'd be curious why one would write the former in the first place.
    Will a programmer or program designer gain something by assigning a
    'float' constant literal to a 'double' variable?

    "double d1 = 0.1;" and "double d2 = 0.1f;" do not put the same value in
    "d1" and "d2". Often the exact value does not matter much, and usually
    when it /does/ matter, the double-precision version is what you want.
    But sometimes people are interested in highly reproducible results from
    their floating point - and that means being precise about the types you
    want.

    I agree that is would be very unusual to want to initialise a
    double-precision variable with a single-precision floating constant. I
    can't think of a circumstance where I would have reason to do so
    directly. I /can/ think of indirect situations:

    #define scale_factor 1.234f
    ...
    #if USE_HIGH_PRECISION
    typedef double calculation_t;
    #else
    typedef float calculation_t;
    #endif
    ...
    calculation_t sf = scale_factor;

    It is more likely that I'd make "scale_factor" a const of type "calculation_t", initialised from "1.234". But perhaps that macro
    constant came from third-party code.


    For more general use of single-precision floating constants, the
    use-cases are clearer.

    First, there is the obvious one that regardless of how the floating
    constant is used, it is clear to the reader that 0.1f is single
    precision. In contexts where speed matters (such as for limited microcontrollers, or where you hope to use SIMD acceleration) you do not
    want to use double precision accidentally - being explicit is better.

    Secondly, narrowing conversions are not allowed in constexpr
    initialisations - you cannot write "constexpr float f = 0.1;". (In C++,
    this also applies to braced initialisation - and is a good reason to use
    such initialisation style.) Static analysis tools may also complain
    about narrowing initialisations.

    And of course we have already covered their use in expressions.


    I've never needed such, erm.., "hacks" ever in any of my C-code or
    in other languages. So I'm honestly asking.


    Sure. I haven't written "double d = 0.1f;" in my code either.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 10:45:16 2026
    On 29/10/2026 02:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    I can't see that parentheses here cause any actual harm - but they are certainly unnecessary fluff, and do no good.

    Every extra level of parentheses adds to the cognitive effort required
    to understand and interpret an expression. It takes longer to read, and
    has a higher chance of misinterpretation. If the parenthesis are
    necessary - "(a + b) * c" - then this is clearly a cost worth paying. Sometimes parentheses are not necessary, but /reduce/ the cognitive
    effort, such as "(a > 2) && (a < 5)". Again, the parentheses are then a
    good thing (albeit subjectively).

    But in "return (x);", they add nothing but cognitive effort. The C programmer's brain has to consider and reject the possibility that this
    is a function call or a macro invocation. The effort is small, but nonetheless wasted.

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them? I
    can see benefits in consistency of style once that usage has been
    established, but why have them in the first place?


    Unlearning is not likely to happen. I've been a long-time
    contributor to FreeBSD, and have no plans to stop. Feel
    free to check the git history on FreeBSD libm sources.
    My finger prints are all over the code. So, yeah, I know
    a enough about floating point arithmetic and C standard
    requirements to be dangerous.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?


    When working on code with particular style requirements, it makes sense
    to follow those style requirements - even if you disagree with the requirements. When working on other code, you are then freed from
    following rules that are unnecessary or counter-productive.

    If I were contributing code to FreeBSD and it /requires/ parentheses in
    return statements for the code to be accepted, I'd put parentheses in
    return statements. If it merely /recommends/ them, I would not do so -
    but would change my mind if other FreeBSD contributors made a fuss about
    it. In no other code would I use them, and in code reviews I would ask
    for them to be removed.

    But I would not bother about them in throw-away Usenet code, except if
    the post was complaining about other unnecessary "fluff" :-)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 10:48:48 2026
    On 28/10/2026 21:25, Michael S wrote:
    On Wed, 28 Oct 2026 08:39:23 +0100
    David Brown <david.brown@hesbynett.no> 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.



    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.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 10:59:24 2026
    On 28/10/2026 23:12, Michael S wrote:
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

    David Brown <david.brown@hesbynett.no> writes:
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;


    David almost certainly was talking about use of 0.1f in arithmetic expressions rather than in simple initialization.

    Yes, that is the most relevant usage.

    But I would not write "float f = 0.1;" either. "float f = 0.1f;" is
    more explicit, and it would not risk accidentally triggering any static analysis (or human analysis) that checks for unintended use of doubles.
    (gcc's "-Wdouble-promotion" does not trigger on "float f = 0.1;", but
    other tools might.)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 11:01:55 2026
    On 28/10/2026 23:33, bartc wrote:
    On 28/10/2026 22:12, Michael S wrote:
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

    David Brown <david.brown@hesbynett.no> writes:
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a difference?

    One simple example: These two declarations result in identical code
    using gcc:

    ˙˙˙˙ float f = 0.1f;
    ˙˙˙˙ float f = 0.1;


    David almost certainly was talking about use of 0.1f in arithmetic
    expressions rather than in simple initialization.



    Yeah, intermediate calculations using 64 bits can give a different and
    more precise result even after it has been converted to 32 bits.

    For example this:

    #include <stdio.h>

    ˙ int main(void) {
    ˙˙˙ float a = 0.1f * 0.1f;
    ˙˙˙ float b = 0.1 * 0.1;

    ˙˙˙ printf("%20.20f\n", a);
    ˙˙˙ printf("%20.20f\n", b);
    ˙˙˙ printf("%20.20f\n", 1 - a * 100);
    ˙˙˙ printf("%20.20f\n", 1 - b * 100);
    ˙ }


    Displays:

    ˙ 0.01000000070780515671
    ˙ 0.00999999977648258209
    ˙-0.00000011920928955078
    ˙ 0.00000000000000000000

    on gcc 9.x on x64.

    It will need the compiler to do the reduction, but DB is likely using a cross-compiler so it is not being done within target device,

    Generally, yes. (Though for this code, the compiler would pre-calculate
    the results at compile time.) My calculations need to be as precise as required for their use - but anything beyond that is just a waste. And
    if the microcontroller has hardware single-precision floating point but
    no double-precision, that wasted runtime is massive.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From makendo@3:633/10 to All on Thu Oct 29 18:04:52 2026
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    And this is why you should use the lowest value denominator when
    storing monetary values -- store USD values in cents, CNY values
    in fen, EUR values in cents, etc...

    I envy in particular the Japanese on this -- they don't have monetary
    units smaller than 1 yen, and as such misuse of floats in monetary
    calculations are far less likely in Japan.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 11:06:44 2026
    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.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 04:54:20 2026
    David Brown <david.brown@hesbynett.no> writes:
    On 29/10/2026 00:08, Janis Papanagnou wrote:
    On 2026-10-28 21:27, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]

    But 0.1f
    and 0.1 are of different types.˙ If they happen to behave the same way
    in some context, it's a consequence of the C language rules.
    Yes, sure. Only that I think that context should suffice to
    interpret
    "0.1" appropriately!

    Do you mean that you think it would have been better if the rules of C
    were different, so that the context always determined how "0.1" was to
    be interpreted? That's not an unreasonable feature for a programming language - AFAIUI, that is how numeric literals work in Ada. But it
    is not how things work in C, where the value and type of an expression
    is determined entirely by the expression itself, independently of the context.

    Strictly speaking, the type of a numeric literal in Ada is
    <universal_integer> or <universal_real>. Both types are anonymous,
    have effectively infinite precision, and exist only at compile time.
    There's an implicit conversion to the type determined by the context
    (one of the few implicit conversions in Ada).

    The effect is similar to what you'd get if the type of a literal
    depending on its context.

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 04:59:06 2026
    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`.)

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 05:01:22 2026
    makendo <makendo@makendo.invalid> writes:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:
    Total
    75.71000000000001 USD
    Appears they may be using FP instead of integer fixed point
    arithmetic
    for pricing.

    And this is why you should use the lowest value denominator when
    storing monetary values -- store USD values in cents, CNY values
    in fen, EUR values in cents, etc...
    [...]

    That's not good enough. Discounts, sales taxes, and compound
    interest can easily result in amounts that are not multiples of
    one cent, which must then be rounded or truncated to the nearest
    cent following whatever financial rules are in effect.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 13:55:54 2026
    On 29/10/2026 13:01, Keith Thompson wrote:
    makendo <makendo@makendo.invalid> writes:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:
    Total
    75.71000000000001 USD
    Appears they may be using FP instead of integer fixed point
    arithmetic
    for pricing.

    And this is why you should use the lowest value denominator when
    storing monetary values -- store USD values in cents, CNY values
    in fen, EUR values in cents, etc...
    [...]

    That's not good enough. Discounts, sales taxes, and compound
    interest can easily result in amounts that are not multiples of
    one cent, which must then be rounded or truncated to the nearest
    cent following whatever financial rules are in effect.


    What is "good enough" depends on the context. For a lot of situations, floating point, or rounding to the nearest dollar (or thousand dollars,
    or pounds, or whatever) can be fine. You can happily use values in
    cents for your shop prices.

    But for accurate financial records used in accounting, tax records,
    banking, etc., you are correct that it is not that simple. Countries
    and groups of countries all have their standards that you need to
    conform to. Typically the way to get correct values is to keep
    everything as large integer types of scaled currency denominations -
    like a thousandth of a cent.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Thu Oct 29 14:32:12 2026
    On 29/10/2026 12:55, David Brown wrote:
    On 29/10/2026 13:01, Keith Thompson wrote:
    makendo <makendo@makendo.invalid> writes:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:
    ˙˙˙˙ Total
    ˙˙˙˙ 75.71000000000001 USD
    Appears they may be using FP instead of integer fixed point
    arithmetic
    for pricing.

    And this is why you should use the lowest value denominator when
    storing monetary values -- store USD values in cents, CNY values
    in fen, EUR values in cents, etc...
    [...]

    That's not good enough.˙ Discounts, sales taxes, and compound
    interest can easily result in amounts that are not multiples of
    one cent, which must then be rounded or truncated to the nearest
    cent following whatever financial rules are in effect.


    What is "good enough" depends on the context.˙ For a lot of situations, floating point, or rounding to the nearest dollar (or thousand dollars,
    or pounds, or whatever) can be fine.˙ You can happily use values in
    cents for your shop prices.

    For /storing/ values in some database, then float binary will be fine,
    evening using dollars and decimals cents such as $1.99.

    But there are a couple of provisos:

    * There is limited precision of some 22 or 23 bits, which caps the
    magnitude that can be represented

    * It must be stipulated that the fractional part always represents
    between 0 and 99 hundredths of a dollar, even if the actual value
    cannot be exact (so 0.75 can be stored exactly, but not 0.74). There
    will never be a value halfway between two consecutive cents.

    With those in place, then any stored value can be converted to an exact
    number of cents (for example, (int)(x*100+0.5) for positive x), or to
    some other exact representation.

    Working directly with such float values is tricky.

    Oh, there is one more proviso: if printing such a value, you must only
    show 2 decimal places, not 14! So you don't get stupid output like 0.74000000953674316 USD.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Thu Oct 29 14:56:16 2026
    In article <11bv4jd$37ch9$1@dont-email.me>,
    David Brown <david.brown@hesbynett.no> wrote:
    [snip]
    Why? What harm do the parentheses cause?

    I can't see that parentheses here cause any actual harm - but they are >certainly unnecessary fluff, and do no good.

    I agree; in my own code, I do not generally use parentheses
    around the expression I give in a `return` statement. But often
    our code is not our own, in the sense that we're constrained by
    working on a much larger project and there are externally
    imposed constraints that we must honor. I don't have to like
    them but, but I do have to abide by them.

    Every extra level of parentheses adds to the cognitive effort required
    to understand and interpret an expression. It takes longer to read, and
    has a higher chance of misinterpretation. If the parenthesis are
    necessary - "(a + b) * c" - then this is clearly a cost worth paying. >Sometimes parentheses are not necessary, but /reduce/ the cognitive
    effort, such as "(a > 2) && (a < 5)". Again, the parentheses are then a
    good thing (albeit subjectively).

    But in "return (x);", they add nothing but cognitive effort. The C >programmer's brain has to consider and reject the possibility that this
    is a function call or a macro invocation. The effort is small, but >nonetheless wasted.

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them? I
    can see benefits in consistency of style once that usage has been >established, but why have them in the first place?

    I mostly agree with you. But when working on a large project,
    that spans many decades, with many different contributers,
    having uniformity is good. You mention cogitive load, but I
    submit that it is strictly worse in that regard to have to deal
    with multiple stylistic differences based on individual
    preference.

    My example is the Google monorepo. When I left Google, it
    contained about 2BLOC of code. All of which more or less
    conformed to Google's mandatory style "guides" (which were only
    "guides" insofar as allowing people to get explicit exemptions
    for very specific reasons from a small group of extremely senior
    engineers: like, Sanjay Ghemawat and Jeff Dean type of senior).

    Personally, I despised the style rules for almost all languages
    Google used; I thought the code was ugly. *But*, after a few
    weeks working in the codebase, they became all but invisible; I
    had to consciously think about them to remember my aesthetic
    objections. Furthermore, I claim that rigid adherence to _a_
    set of rules, no matter how ugly I thought they were, was a big
    factor in allowing Google to scale to tends of thousands of
    engineers working concurrently in a multi-billion line codebase.

    Put another way, it is more important to have _a_ style that is
    used uniformly, while it is relatively less important what rules
    that style imposes.

    [snip]
    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    A metanote, not to David, but of course, reference to the
    `style(9)` man page _strengthens_ the argument for
    parenthesizing return'ed expressions when working with FreeBSD
    code. In fairness, it wasn't clear that that was the original
    context.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    When working on code with particular style requirements, it makes sense
    to follow those style requirements - even if you disagree with the >requirements. When working on other code, you are then freed from
    following rules that are unnecessary or counter-productive.

    If I were contributing code to FreeBSD and it /requires/ parentheses in >return statements for the code to be accepted, I'd put parentheses in
    return statements. If it merely /recommends/ them, I would not do so -
    but would change my mind if other FreeBSD contributors made a fuss about
    it. In no other code would I use them, and in code reviews I would ask
    for them to be removed.

    But I would not bother about them in throw-away Usenet code, except if
    the post was complaining about other unnecessary "fluff" :-)

    I do not find the amount of heat this has generated particularly
    useful. The parentheses may be superfluous, but they're not
    wrong, and if OP prefers to include them, it does no harm; in
    this case, there's a very good reason: OP works with FreeBSD
    code often, which mandates them; maintaining two separate styles
    to appease the USENET crowd is probably more cognitive effort
    than mentally blocking them out for a `return`.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Thu Oct 29 11:56:38 2026
    On 2026-10-28 21:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they nominally know better. What would you think of

    return (a=b).retval;

    You might never write such code, and might never read it either, but you
    should have no trouble parsing it. Do you?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Thu Oct 29 16:34:44 2026
    On Thu, 29 Oct 2026 10:45:16 +0100, David Brown wrote:

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them? I
    can see benefits in consistency of style once that usage has been established, but why have them in the first place?


    As we all know, FreeBSD is derived from software developed by
    the CSRG at UC Berkeley during the 70's. FreeBSD adopted the
    Kernel Normal Format (KNF) from CSRG. You will need to contact
    a former member of CSRG such as Bostik, McKusick, Joy, Leffler,
    etc. and them why KNF requires ().

    Perhaps, the C compiler from 40 or so years ago required
    parentheses in a return statement. Or, just maybe, members of
    CSRG read K&R and noticed the authors of the book consistently
    use paretheses in their examples. Ah yes, let's look at
    the documentation:

    % man 9 style

    HISTORY
    This manual page was originally based on the src/admin/style/style file
    from the 4.4BSD-Lite2 release, with frequent updates to reflect the
    current practice and desire of the FreeBSD project.
    src/admin/style/style is a codification by the CSRG of the programming
    style of Ken Thompson and Dennis Ritchie in Version˙6 AT&T UNIX.

    So, it seems to be a preference of Ritchie.

    --
    steve


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 17:58:38 2026
    On 2026-10-29 02:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    [...], and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    [...]

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    Unlearning is not likely to happen. [...]

    I understand that long fostered habits are hard to change, so I
    certainly wouldn't criticize that; and especially since they do
    no harm as you say. (They're only "unnecessary fluff".)

    [BSD style]
    % man 9 style
    ...
    Values in return statements should be enclosed in parentheses.
    [...]
    [...]

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    Following some projects' style requirements is certainly the most
    important argument here!


    Myself I started with "C" using parenthesis - and I wondered why!
    The reason (in my case) was obviously that this had been the style
    that was regularly used in the _K&R book_ (where I learned the "C"
    language from).

    But at some point (meanwhile decades ago) when I got aware that the
    parenthesis are unnecessary I immediately switched to the (IMO)
    much cleaner form without the spurious parenthesis. (There's already
    far too many [mandatory] parenthesis in the language, to my taste.)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 18:55:59 2026
    On 2026-10-29 00:56, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-10-28 21:27, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    The thought of something "implicit" going on here is a thought that
    might stem from (knowing) the inherent mechanisms and quirks of the
    C-language not necessarily what one would logically expect.
    My logical expectation is based on knowing C.

    And knowing also a lot of the internals, and C-standards documents,
    I'm sure. (My point was just that "normal" C-programmers might not
    have that background and would "logically" assume different. - But
    since you had clarified the word by using a more appropriate one in
    this post I'm fine with that now. Thanks.)

    My expectation (for sensibly defined programming languages) would be
    that literals for two different "real numbers" types are generic WRT
    those types; they should be usable [in "C"] without loss (or kludges)
    with 'float' and 'double'.
    Sure, a compiler can generate code to store (float)0.1 in f without
    doing a conversion, as long as the semantics are consistent.

    Only that my view here is that you need a "conversion" in both cases,
    since you primarily have to convert from a string representation of
    the literal to the appropriate internal (binary) form. And given the
    _program contexts_ you can do _the one_ appropriate conversion for
    the types involved (i.e. Text->Float and Text->Double, respectively).

    I don't think of the process that takes a source code construct
    like `0.1` and yields a value of 0.1 at run time as a "conversion".
    It's just the meaning of the token. "Text" is not a C type. [...]

    Sure. I was speaking about source code text, that gets transformed
    to some binary representation by the compiler. I took the view from
    a programmer's perspective of a language; to be clear, not mandating
    (as some here do) that a programmer should read the C-standard to
    learn and understand the language, but as more typical, a textbook.


    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    By 'F', you mean the 'f' or 'F' suffix on a floating constant, right?
    (Your use of upper case threw me off for a moment. No biggie.)

    Yes. (Didn't intend to confuse people.) I'm regularly using (in "C")
    capital letters for such qualifiers, so that they better stand out.
    The 'L' for example (that I use more often; 'F' I've never used since
    I also rarely do 'float' operations) is often (depending on the font)
    harder to distinguish (from '1') if written in lower-case ('l').


    (And, ideally, practically relevant usages. - We know that "C" is as
    it is, and as it is there's some unavoidable consequences from that.)

    Yes, we know that from "C", which is the topic of this newsgroup.
    I'm not sure what distinction you're making.

    I wanted to avoid reflexes like "accept how it is or leave" comments.
    (I obviously failed with making that intent clear.)

    As I've explained above, I was looking at it from a programmer's
    perspective, not from someone who has the C-standard as bible on his nightstand. With experiences from many other languages the "F-topic",
    its necessity, is not that clear if we look at "C" conceptionally.

    You seem to be
    implying that C imposes some set of obscure rules on top of what
    all programmers know. 0.0 is something that everyone recognizes,
    while 0.0f is an obscure C feature.

    (I think 0 is a bad example, for some reasons in "C" and general.)

    That "0.1" is (or may be, depending on the actual 'float' and 'double' characteristics) effectively something different than "0.1F" is the
    trivial part, unnecessary to explain. I had expanded below what was
    bothering me.


    I don't think of it that way. C code is governed by the rules of C.

    But 0.1f and 0.1 are of different types. If they happen to behave
    the same way in some context, it's a consequence of the C language
    rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!

    In many cases, yes, the final result is likely to be the same.
    Even so, using 0.1 rather than 0.1f can result in less efficient
    generated code if the compiler isn't sufficiently clever, or perhaps
    even if it is.

    And if I'm trying to use type float and avoid type double (as, for
    example, David Brown has good reasons to do), writing `0.1f` is a
    great way to avoid having to think about how clever the compiler
    has to be to avoid unnecessary conversions.

    Actually I had been thinking about applications that David might
    have - I recall he once said about him using 'float' to match some
    controller hardware restrictions and stay efficient (or some such).

    And while the initialization sample (below) did not make any sense
    to me I was then thinking about expressions with mixed types where
    it could make sense. But the consequences did also not make "much"
    sense to me when thinking about it. Two basic cases appeared to me.
    One was having expressions with mixed types (float and double);
    in the micro-controller-case that would anyway have to be handled
    in a sub-optimal way (performance-wise) when 'double's appear. And
    in case of using just 'float' variables with non-F-tagged constants
    my expectation would be that the compiler would/should take care of
    the appropriate, sensible, efficient use of the constant. (Operating
    in 'float' precision but interpreting "Real" literals as 'double'?!)
    You say, "avoid having to think about how clever the compiler" is;
    I understand that. But wouldn't it be more sensible to compose your
    "Real" expressions in appropriate parts that reflect and guarantee
    the precision explicitly? (As "C" is as it is it might be appealing
    to use the 'F' instead, I admit. As said I was principally question
    the necessity of 'F' in "C" from a design perspective.)


    Note in particular that this:
    double d = 0.1f;
    has different semantics than
    double d = 0.1;
    if double has more precision than float.

    Sure. But isn't that difference basically just a home-brewed C-issue?

    "Home-brewed"? It's a rule imposed by the C language.

    (I meant; is it a "home-brewed" consequence of the C-language design.)


    I'd be curious why one would write the former in the first place.
    Will a programmer or program designer gain something by assigning a
    'float' constant literal to a 'double' variable?

    Probably not. The point is that there are real semantic differences
    between 0.1f and 0.1.

    Sure.

    Janis

    [...]


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Thu Oct 29 17:57:15 2026
    On Thu, 29 Oct 2026 11:56:38 -0400, James Kuyper wrote:

    On 2026-10-28 21:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they nominally know better. What would you think of

    return (a=b).retval;

    You might never write such code, and might never read it either, but you should have no trouble parsing it. Do you?

    Never written nor seen such a line of code. Of course, a random
    line of code taken out of context may have many interpretations
    or no interpretation at all. I likely know less than 25% of
    what C can do as I am primarily interested in only C23 7.12 and
    Annex F and G.

    I do find it interesting that in a newgroup purportedly concerned
    with discussions about the C programming language, I seem to have
    been the only person in this thread to show a complete self-contained
    piece of code so fir can see the consequences of not understanding
    floating point arithmetic.

    --
    steve


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 19:57:19 2026
    On 2026-10-29 09:30, David Brown wrote:
    On 29/10/2026 00:08, Janis Papanagnou wrote:
    On 2026-10-28 21:27, Keith Thompson wrote:
    [...]
    But 0.1f
    and 0.1 are of different types.˙ If they happen to behave the same way
    in some context, it's a consequence of the C language rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!


    Do you mean that you think it would have been better if the rules of C
    were different, so that the context always determined how "0.1" was to
    be interpreted?

    (I think my opinion here is irrelevant since "C" is what it is.)

    But, yes, my question was whether it would haven been necessary
    (language design-wise!) to have those tags in the first place.

    That's not an unreasonable feature for a programming
    language - AFAIUI, that is how numeric literals work in Ada.˙ But it is
    not how things work in C, where the value and type of an expression is determined entirely by the expression itself, independently of the context.

    I hate to try to speculate as to whether the C philosophy or the Ada philosophy here is more common -

    (I also have no interest in speculations.)

    but I don't know of any languages other
    than Ada that make the type of literals dependent on their use or
    context.˙ There are of course many languages that might follow the Ada
    path, unbeknownst to me.˙ (You can have fun making class types in C++,
    and no doubt other languages, that emulate this behaviour, but it is not part of the language.)

    (Here I had started writing examples from other languages, but it
    got long and no end to see, and it's anyway most likely considered
    off-topic, so I decided to just stop here.)

    Thanks for your elaborations on the question.

    Janis

    [...]


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Thu Oct 29 19:49:03 2026
    In article <11bvqbn$3g0tj$1@dont-email.me>,
    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    On 2026-10-28 21:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they >nominally know better.

    What? This is an incredibly weak argument.

    If someone thought that `return` was a function, then why
    wouldn't they think that `if` or `while` were also functions?
    Or `sizeof`, and so on?

    What would you think of

    return (a=b).retval;

    You might never write such code, and might never read it either, but you >should have no trouble parsing it. Do you?

    I would think that code is bad, and unnecessarily obscure, but
    perhaps someone _would_ write this code.

    struct v {
    int retval;
    };

    struct v a;

    int
    something(void)
    {
    struct v b;
    b.retval = 1;
    return (a=b).retval;
    }

    Of course, it would make no difference if the `return` statement
    were written as,

    return ((a=b).retval);

    But again, the whole premise (that a programmer familiar with C
    would ever think that `return` is a function) is silly.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Thu Oct 29 20:56:39 2026
    On 29/10/2026 19:57, Janis Papanagnou wrote:
    On 2026-10-29 09:30, David Brown wrote:
    On 29/10/2026 00:08, Janis Papanagnou wrote:
    On 2026-10-28 21:27, Keith Thompson wrote:
    [...]
    But 0.1f
    and 0.1 are of different types.˙ If they happen to behave the same way >>>> in some context, it's a consequence of the C language rules.

    Yes, sure. Only that I think that context should suffice to interpret
    "0.1" appropriately!


    Do you mean that you think it would have been better if the rules of C
    were different, so that the context always determined how "0.1" was to
    be interpreted?

    (I think my opinion here is irrelevant since "C" is what it is.)

    There's nothing wrong with having an opinion on what might or might not
    have been better, or what you might like in other languages. The
    pointless discussions come from claiming C can be, or needs to be, "fixed".

    But it's fine to stop here if you like.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Thu Oct 29 13:39:55 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 22:55:31 2026
    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.

    Yes, that's hard to believe.

    I've heard the argument somehow reversed, alike "You don't need
    the parenthesis since 'return' is a statement (and no function)."
    IOW, it was not about mistaking 'return' for a function, more to
    make its _character as statement_ clear (and by that, en passant,
    invalidate K&R's paragon which had been widely followed back then).

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 23:06:59 2026
    On 2026-10-29 20:56, David Brown wrote:

    There's nothing wrong with having an opinion on what might or might not
    have been better, or what you might like in other languages.˙ The
    pointless discussions come from claiming C can be, or needs to be, "fixed".

    "Abandon all hope, ye who enter here." :-)

    But it's fine to stop here if you like.

    Yes, I think it makes little sense. It's also hard to compare
    languages on a specific feature alone without taking its whole
    design into account. The 'F' tag is just a detail of the issue
    (or "issue", in quotes, if you prefer) with types in "C". (IMO)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Thu Oct 29 23:19:48 2026
    On 2026-10-29 13:01, Keith Thompson wrote:
    makendo <makendo@makendo.invalid> writes:
    I ordered a couple of blu-rays from amazon last week, and the
    confirmation email had the following for the total price:
    Total
    75.71000000000001 USD
    Appears they may be using FP instead of integer fixed point
    arithmetic
    for pricing.

    And this is why you should use the lowest value denominator when
    storing monetary values -- store USD values in cents, CNY values
    in fen, EUR values in cents, etc...
    [...]

    That's not good enough. Discounts, sales taxes, and compound
    interest can easily result in amounts that are not multiples of
    one cent, which must then be rounded or truncated to the nearest
    cent following whatever financial rules are in effect.

    We also have to consider conversions of currencies between states
    in international trade, or, at times, switch of a currency unit;
    e.g. 1 Euro = 1,95583 DEM (note the officially defined number of
    decimals).

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Thu Oct 29 15:42:26 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    Wrong question. The important question is what benefit do they
    give? Granted, there may be circumstances where there is some
    benefit. But what benefit justifies using parentheses in *all*
    circumstances?

    Unlearning is not likely to happen. I've been a long-time
    contributor to FreeBSD, and have no plans to stop. Feel
    free to check the git history on FreeBSD libm sources.
    My finger prints are all over the code. So, yeah, I know
    a enough about floating point arithmetic and C standard
    requirements to be dangerous.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    Please note what I said. I did not say never to use parentheses.
    What I did say is that now is a good time to start unlearning the
    habit of (always) using parentheses. If you're writing code
    destined for FreeBSD, by all means put in the extra parentheses.
    On the other hand, if you're writing code to put in a posting for
    comp.lang.c, it's more common not to use extra parentheses. When
    in Rome, do as the Romans do. If you have a compelling reason to
    use such redundant parentheses here in the newsgroup, please tell
    us what it is. Otherwise, is it you who is ignoring the style
    norms of the group who will be reading your code?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Thu Oct 29 15:47:26 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Thu, 29 Oct 2026 10:45:16 +0100, David Brown wrote:

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them?
    I can see benefits in consistency of style once that usage has been
    established, but why have them in the first place?

    As we all know, FreeBSD is derived from software developed by
    the CSRG at UC Berkeley during the 70's. FreeBSD adopted the
    Kernel Normal Format (KNF) from CSRG. You will need to contact
    a former member of CSRG such as Bostik, McKusick, Joy, Leffler,
    etc. and them why KNF requires ().

    Perhaps, the C compiler from 40 or so years ago required
    parentheses in a return statement. Or, just maybe, members of
    CSRG read K&R and noticed the authors of the book consistently
    use paretheses in their examples. Ah yes, let's look at
    the documentation:

    % man 9 style

    HISTORY
    This manual page was originally based on the src/admin/style/style
    file from the 4.4BSD-Lite2 release, with frequent updates to
    reflect the current practice and desire of the FreeBSD project.
    src/admin/style/style is a codification by the CSRG of the
    programming style of Ken Thompson and Dennis Ritchie in Version6
    AT&T UNIX.

    So, it seems to be a preference of Ritchie.

    It may have been simply long-standing habit rather than preference.
    In the early days of C parentheses around return expressions were
    required, not optional. I've been programming in C long enough to
    have been influenced by that requirement (and later learned to undo
    it).

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 16:06:03 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Thu, 29 Oct 2026 11:56:38 -0400, James Kuyper wrote:
    On 2026-10-28 21:50, Steven G. Kargl wrote:
    [...]
    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they
    nominally know better. What would you think of

    return (a=b).retval;

    You might never write such code, and might never read it either, but you
    should have no trouble parsing it. Do you?

    Never written nor seen such a line of code. Of course, a random
    line of code taken out of context may have many interpretations
    or no interpretation at all. I likely know less than 25% of
    what C can do as I am primarily interested in only C23 7.12 and
    Annex F and G.

    (7.12 is <math.h>; Annexes F and G are ISO/IEC 60559 arithmetic.)

    The question isn't whether you've ever seen such code (which I'm
    guessing James made up as an example). The question is whether
    you can easily understand it. Someone who had a mental model that
    return requires parentheses would likely have trouble with it. (And
    in fact very early versions of C did require parentheses on return
    statements with an expression.)

    I do find it interesting that in a newgroup purportedly concerned
    with discussions about the C programming language, I seem to have
    been the only person in this thread to show a complete self-contained
    piece of code so fir can see the consequences of not understanding
    floating point arithmetic.

    You may be one of the few people who's willing to engage with fir.
    I didn't reply to him because I don't read his posts.

    Are you the same person as steve g <Sgonedes1977@gmail.com>?

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 16:29:32 2026
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <11bvqbn$3g0tj$1@dont-email.me>,
    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    On 2026-10-28 21:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:
    (Also, you misspelled "ROFL", and you don't need parentheses on the >>>>>> return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they >>nominally know better.

    What? This is an incredibly weak argument.

    If someone thought that `return` was a function, then why
    wouldn't they think that `if` or `while` were also functions?
    Or `sizeof`, and so on?

    I agree that it's a bit of a weak argument, but I wouldn't call it
    incredibly weak.

    In my personal coding style, I try to avoid making things that are not
    function calls look like function calls. In a function call, there's no
    space between the function name and the left parenthesis. I don't use
    that style for anything other than function calls (or invocations of function-like macros). Not because I don't know return and sizeof are keywords, but because it's just a little bit easier to read the code
    if distinctions like that are clear.

    Examples:

    func(42); // function call, or maybe a macro invocation
    return 42; // not return(42); or even "return (42);
    if (cond) // not if(cond)
    sizeof (int) // not sizeof(int)
    sizeof obj // not sizeof(obj) or sizeof (obj)

    The idea is to make the code just a little bit clearer and easier to
    read. If I see something that looks it would be a function call except
    that the prefix is a keyword, it's *very slightly* annoying.
    Parentheses on a return statement are allowed, but they're part of the expression, not part of the syntax of the return statement, and they're superfluous. I don't write `return (42);` for the same reason I don't
    write `x = (42);`.

    And of course *all* of these rules can be overridden by a coding
    standard or by the existing style of the surrounding code.

    [...]
    But again, the whole premise (that a programmer familiar with C
    would ever think that `return` is a function) is silly.

    The premise (at least for me) is not that someone would *think*
    that return is a function, but that making a return statement not
    look too much like a function call makes the code just a little
    bit easier to read.

    And in the example that started this subthread, I probably wouldn't
    have mentioned the parentheses if the poster hadn't been complaining
    about "fluff".

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Thu Oct 29 23:46:28 2026
    On Thu, 29 Oct 2026 11:56:38 -0400, James Kuyper wrote:

    They can lead to people thinking that return is a function ...

    There shouldn?t be a return statement at all. Smashing together the
    assignment of the function result with termination of function
    execution seems to me a code smell.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 16:46:38 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Thu, 29 Oct 2026 10:45:16 +0100, David Brown wrote:

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them? I
    can see benefits in consistency of style once that usage has been
    established, but why have them in the first place?

    As we all know, FreeBSD is derived from software developed by
    the CSRG at UC Berkeley during the 70's. FreeBSD adopted the
    Kernel Normal Format (KNF) from CSRG. You will need to contact
    a former member of CSRG such as Bostik, McKusick, Joy, Leffler,
    etc. and them why KNF requires ().

    Perhaps, the C compiler from 40 or so years ago required
    parentheses in a return statement. Or, just maybe, members of
    CSRG read K&R and noticed the authors of the book consistently
    use paretheses in their examples. Ah yes, let's look at
    the documentation:

    % man 9 style

    HISTORY
    This manual page was originally based on the src/admin/style/style file
    from the 4.4BSD-Lite2 release, with frequent updates to reflect the
    current practice and desire of the FreeBSD project.
    src/admin/style/style is a codification by the CSRG of the programming
    style of Ken Thompson and Dennis Ritchie in Version˙6 AT&T UNIX.

    So, it seems to be a preference of Ritchie.

    A former preference.

    In the 1975 C reference manual, the syntax for a return statement was:

    return ;
    return ( expression ) ;

    In K&R1, 1978, the syntax was changed to:

    return ;
    return expression ;

    but parentheses were used in the examples.

    In K&R2, 1988, the examples did not use parentheses on return
    statements. (I don't know whether that was Ritchie's decision or
    Kernighan's.)

    It appears that the FreeBSD style rule is a relic of an earlier
    version of C that required the parentheses. AT&T V6 Unix was
    released in 1975.

    You can still use parentheses on return statements if you want to,
    and you should do so if you're operating under a coding standard
    that requires them. They're part of the syntax of the expression,
    not part of the syntax of the return statement. I probably wouldn't
    have said anything if you hadn't mocked the use of 25.0 or 25.0f
    rather than 25 as "fluff".

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 16:56:32 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    For now. In the latest C2y draft, they're called literals.

    Proposal: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3189.htm Draft standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3998.pdf

    (You've said before that you dislike this change.)

    In any case, the term "literal" is unambiguous, even if it's not
    currently used by the C standard.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Fri Oct 30 00:21:30 2026
    On Thu, 29 Oct 2026 16:06:03 -0700, Keith Thompson wrote:

    You may be one of the few people who's willing to engage with fir.
    I didn't reply to him because I don't read his posts.

    I usually skip fir's post, but this one caught my eye
    as it was a question about floating point.

    Are you the same person as steve g <Sgonedes1977@gmail.com>?

    No.

    --
    steve

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Fri Oct 30 00:50:57 2026
    On Thu, 29 Oct 2026 18:04:52 +0800, makendo wrote:

    I envy in particular the Japanese on this -- they don't have
    monetary units smaller than 1 yen, and as such misuse of floats in
    monetary calculations are far less likely in Japan.

    1 yen = 100 sen = 1000 rin

    ?The sen and the rin were eventually taken out of circulation at
    the end of 1953?
    -- <https://en.wikipedia.org/wiki/Japanese_yen>

    How would you do calculations involving compound interest payments
    without floating-point arithmetic? And why would you want to?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Fri Oct 30 01:17:39 2026
    In article <86o6cckttt.fsf@linuxsc.com>,
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Thu, 29 Oct 2026 10:45:16 +0100, David Brown wrote:

    Let me put it another way. What benefit do you think there is from
    these parentheses? Why does the FreeBSD style guide recommend them?
    I can see benefits in consistency of style once that usage has been
    established, but why have them in the first place?

    As we all know, FreeBSD is derived from software developed by
    the CSRG at UC Berkeley during the 70's. FreeBSD adopted the
    Kernel Normal Format (KNF) from CSRG. You will need to contact
    a former member of CSRG such as Bostik, McKusick, Joy, Leffler,
    etc. and them why KNF requires ().

    Perhaps, the C compiler from 40 or so years ago required
    parentheses in a return statement. Or, just maybe, members of
    CSRG read K&R and noticed the authors of the book consistently
    use paretheses in their examples. Ah yes, let's look at
    the documentation:

    % man 9 style

    HISTORY
    This manual page was originally based on the src/admin/style/style
    file from the 4.4BSD-Lite2 release, with frequent updates to
    reflect the current practice and desire of the FreeBSD project.
    src/admin/style/style is a codification by the CSRG of the
    programming style of Ken Thompson and Dennis Ritchie in Version6
    AT&T UNIX.

    So, it seems to be a preference of Ritchie.

    It may have been simply long-standing habit rather than preference.
    In the early days of C parentheses around return expressions were
    required, not optional. I've been programming in C long enough to
    have been influenced by that requirement (and later learned to undo
    it).

    When? They were not required in typesetter C on 7th Edition
    Unix, which is more or less what K&R described, and the grammar
    in K&R1 just says `return _expression_;`:

    ```
    $ ed paren.c
    ?paren.c
    a
    #include <stdio.h>

    int
    foo()
    {
    return 2;
    }

    int
    main()
    {
    printf("foo() = %d\n", foo());
    return 0;
    }
    .
    w
    104
    q
    $ cc -o paren paren.c
    $ ./paren
    foo() = 2
    $
    ```

    Nor were they required in the rather different dialect used in
    6th Edition Unix:

    ```
    RESTRICTED RIGHTS

    Use, duplication or disclosure is subject to
    restrictions stated in Contract with Western
    Electric Company, Inc.

    login: root
    # cat >paren.c
    foo()
    {
    return 2;
    }

    int
    main()
    {
    printf("foo() = %d\n", foo());
    return 0;
    }
    # cc paren.c
    # ./a.out
    foo() = 2
    #
    ```

    Neither the parser in the 5th Edition compiler nor the 4th Ed
    compiler (the latter from the recently recovered tape found at
    Utah) requires parentheses in that position, either.

    They _are_ required in the earliest extant compiler sources from
    roughly 1972 (the `last1120c` and `prestruct-c` compilers
    recovered from DECtape and published by Dennis Ritchie on his
    web page), and it is true that the, "C Reference Manual" from
    6th Ed shows parentheses around the expression in a `return`
    statement; as mentioned, the 6th Ed compiler did not enforce
    this, however.

    It looks like parentheses were grammatically required around the
    expression in a `return` statement for a brief period ca. 1972,
    perhaps into early 1973, and never after that. Certainly, I do
    not believe that anyone posting here ever used one of the early
    compilers that required this, unless it was an ersatz
    implementation.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Fri Oct 30 01:27:03 2026
    In article <86se1oku25.fsf@linuxsc.com>,
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the
    return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    Wrong question. The important question is what benefit do they
    give? Granted, there may be circumstances where there is some
    benefit. But what benefit justifies using parentheses in *all* >circumstances?

    Consistency with existing code and conformance with an
    externally mandated style guide, obviously.

    Unlearning is not likely to happen. I've been a long-time
    contributor to FreeBSD, and have no plans to stop. Feel
    free to check the git history on FreeBSD libm sources.
    My finger prints are all over the code. So, yeah, I know
    a enough about floating point arithmetic and C standard
    requirements to be dangerous.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    Please note what I said. I did not say never to use parentheses.
    What I did say is that now is a good time to start unlearning the
    habit of (always) using parentheses. If you're writing code
    destined for FreeBSD, by all means put in the extra parentheses.
    On the other hand, if you're writing code to put in a posting for >comp.lang.c, it's more common not to use extra parentheses. When
    in Rome, do as the Romans do. If you have a compelling reason to
    use such redundant parentheses here in the newsgroup, please tell
    us what it is. Otherwise, is it you who is ignoring the style
    norms of the group who will be reading your code?

    This newsgroup has no "norms" for code style. Period.

    You are stating your preference as if it is some agreed upon, de
    facto standard. It is not, nor is it a requirement for posting
    here. No one posting here is obligated to omit the parentheses
    to satisfy the whims of you, me, or anyone else. Hell, they can
    unironically use the GNU style if they really want.

    OP: you want to parenthesize the expression in a `return`
    statement because that's what you're used to from FreeBSD? Go
    for it. Some folks may find it unnecessary; that's fine. But
    don't listen to someone trying to tell you that you're violating
    some set of invisible mores by doing so; that nonsense.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Thu Oct 29 18:37:16 2026
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:

    On Thu, 29 Oct 2026 11:56:38 -0400, James Kuyper wrote:

    They can lead to people thinking that return is a function ...

    There shouldn't be a return statement at all. Smashing together
    the assignment of the function result with termination of function
    execution seems to me a code smell.

    It must be terrible to have such a highly sensitive nose in a world
    with so many heathen programming language designers.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Steven G. Kargl@3:633/10 to All on Fri Oct 30 02:08:10 2026
    On Fri, 30 Oct 2026 01:27:03 -0000 (UTC), Dan Cross wrote:

    In article <86se1oku25.fsf@linuxsc.com>,
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:

    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:

    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:

    (Also, you misspelled "ROFL", and you don't need parentheses on the >>>>>> return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    Wrong question. The important question is what benefit do they
    give? Granted, there may be circumstances where there is some
    benefit. But what benefit justifies using parentheses in *all* >>circumstances?

    Consistency with existing code and conformance with an
    externally mandated style guide, obviously.

    Unlearning is not likely to happen. I've been a long-time
    contributor to FreeBSD, and have no plans to stop. Feel
    free to check the git history on FreeBSD libm sources.
    My finger prints are all over the code. So, yeah, I know
    a enough about floating point arithmetic and C standard
    requirements to be dangerous.

    % man 9 style
    ...

    Values in return statements should be enclosed in parentheses.


    I also have debugging macros RETURNI() that require parens.

    That strengthens the motivation not to use parentheses with
    return statements, to emphasize that they are different from
    the macros.

    Do you ignore the style requirements of all the projects
    that you may have worked on, and simply use whatever
    your personal preferences are?

    Please note what I said. I did not say never to use parentheses.
    What I did say is that now is a good time to start unlearning the
    habit of (always) using parentheses. If you're writing code
    destined for FreeBSD, by all means put in the extra parentheses.
    On the other hand, if you're writing code to put in a posting for >>comp.lang.c, it's more common not to use extra parentheses. When
    in Rome, do as the Romans do. If you have a compelling reason to
    use such redundant parentheses here in the newsgroup, please tell
    us what it is. Otherwise, is it you who is ignoring the style
    norms of the group who will be reading your code?

    This newsgroup has no "norms" for code style. Period.

    You are stating your preference as if it is some agreed upon, de
    facto standard. It is not, nor is it a requirement for posting
    here. No one posting here is obligated to omit the parentheses
    to satisfy the whims of you, me, or anyone else. Hell, they can
    unironically use the GNU style if they really want.

    OP: you want to parenthesize the expression in a `return`
    statement because that's what you're used to from FreeBSD? Go
    for it. Some folks may find it unnecessary; that's fine. But
    don't listen to someone trying to tell you that you're violating
    some set of invisible mores by doing so; that nonsense.

    I have been lurking in c.l.c for over 2 decades. I know that
    there is no coding style guide, here. I have contributed code
    to both FreeBSD and GCC, again, for over 2 decades. I'm
    well-aware of the requirements in both FreeBSD's style(9) and
    the GNU coding standard. Neither use my preferred 3-space
    indentation at all indentation levels. Oh well.

    C23, Annex A shows the syntax rule: 'return expression_{opt}'
    with _{opt} denoting a subscript. Unsurprisingly, 6.5.2 shows

    primary-expression:
    ...
    ( expression )
    ...

    so, the code I posted with 'return (0)' is standard conforming.

    --
    steve


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 19:37:39 2026
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    [...]
    C23, Annex A shows the syntax rule: 'return expression_{opt}'
    with _{opt} denoting a subscript. Unsurprisingly, 6.5.2 shows

    primary-expression:
    ...
    ( expression )
    ...

    so, the code I posted with 'return (0)' is standard conforming.

    Of course, and nobody has suggested otherwise.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 03:57:56 2026
    On 2026-10-30 00:29, Keith Thompson wrote:
    [...]
    [...]

    In my personal coding style, I try to avoid making things that are not function calls look like function calls. In a function call, there's no space between the function name and the left parenthesis. [...]

    I suppose we should read the second sentence also as your "personal
    coding style". In my personal coding style there's usually always a
    space. (Exception to that habit is in user-defined functions' calls
    in Awk where it is required by the syntax, a is space disallowed.)

    [...]

    And in the example that started this subthread, I probably wouldn't
    have mentioned the parentheses if the poster hadn't been complaining
    about "fluff".

    Yeah, that was funny. :-)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 04:22:00 2026
    On 2026-10-30 00:46, Lawrence D?Oliveiro wrote:
    On Thu, 29 Oct 2026 11:56:38 -0400, James Kuyper wrote:

    They can lead to people thinking that return is a function ...

    There shouldn?t be a return statement at all. Smashing together the assignment of the function result with termination of function
    execution seems to me a code smell.

    I sense you may have the Algol 68 structure in mind (where all
    clauses just return the value that is _plainly stated_ without
    keyword); which is indeed very elegant for "normal" exits from
    functions. But we have to remember how "hard" (= ugly) it is
    to _early exit_ from functions there, needing an extra keyword,
    a special syntax rule, and a jump/label.

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 04:38:02 2026
    On 2026-10-30 00:56, Keith Thompson wrote:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    For now. In the latest C2y draft, they're called literals.

    Proposal: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3189.htm Draft standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3998.pdf

    (You've said before that you dislike this change.)

    In any case, the term "literal" is unambiguous, even if it's not
    currently used by the C standard.

    Thanks for answering him. (As I'm yet again ignoring him I wouldn't
    have noticed his statement.)

    For other readers I remind that I'm not necessarily using C-standard
    terms if there's terms common in CS existing that either appear more appropriately describing things, or if I'm generalizing facts beyond
    "C".

    It's noteworthy that the new C-standard draft is using that term;[*]
    I didn't know that, so also thanks also for that information.

    Janis

    [*] May we interpret that fact as C-standard terms might eventually
    converge to a more commonly accepted "beyond C standard" terminology?
    (I expect no answer. - It was just some pondering aloud.)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 20:53:31 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-10-30 00:29, Keith Thompson wrote:
    [...]
    [...]
    In my personal coding style, I try to avoid making things that are
    not
    function calls look like function calls. In a function call, there's no
    space between the function name and the left parenthesis. [...]

    I suppose we should read the second sentence also as your "personal
    coding style".

    Yes, of course.

    In my personal coding style there's usually always a
    space.

    Then you're objectively wrong.

    (I kid, I kid!)

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 05:01:20 2026
    On 2026-10-30 01:50, Lawrence D?Oliveiro wrote:
    [...]

    How would you do calculations involving compound interest payments
    without floating-point arithmetic? And why would you want to?

    Because what gets in and what comes out is just exact fixed point?
    And you need more an exact transformation to and from the internal
    values? And exact representation with BCD more than binary floating
    point? (Mind the 0.10 issue!) - I think there was a reason why with
    COBOL, the COmmon Business Oriented Language, there was - at least
    historically - fixed-point arithmetic used for the financial sector?
    (But please CMIIW.)

    Would there be a problem with fixed-point arithmetic (that internally
    uses a few more than just two decimals for rounding etc.) but that is
    using basically a fixed-point representation?

    And we saw in some post this hilarious sample of an (Amazon?) bill.
    (Not that this couldn't have been fixed even/also with FP-arithmetic.)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 05:06:34 2026
    On 2026-10-30 04:53, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    In my personal coding style there's usually always a space.

    Then you're objectively wrong.

    (I kid, I kid!)

    *phew!*

    Oh, please, mind my heart - for a moment it stopped beating!

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Thu Oct 29 21:17:13 2026
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    [...]
    How would you do calculations involving compound interest payments
    without floating-point arithmetic?

    Because you'd want to follow the standards for financial calculations,
    which are likely to require some kind of fixed-point.

    And why would you want to?

    To obtain the exact results required by the relevant financial
    regulations, and to avoid accusations of malfeasance.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Oct 30 09:11:50 2026
    On 30/10/2026 04:38, Janis Papanagnou wrote:
    On 2026-10-30 00:56, Keith Thompson wrote:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Note: my argumentation is based on questioning the existence of 'F'.
    So I'd appreciate to hear of any enlightening application cases, ones
    that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    For now.˙ In the latest C2y draft, they're called literals.

    Proposal:˙˙˙˙˙˙ https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3189.htm
    Draft standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3998.pdf

    (You've said before that you dislike this change.)

    In any case, the term "literal" is unambiguous, even if it's not
    currently used by the C standard.

    Thanks for answering him. (As I'm yet again ignoring him I wouldn't
    have noticed his statement.)

    For other readers I remind that I'm not necessarily using C-standard
    terms if there's terms common in CS existing that either appear more appropriately describing things, or if I'm generalizing facts beyond
    "C".

    The preference should be to use the C standard terms in this group - or
    to add brief comments for clarity. (Sometimes it is also worth adding comments for clarity even when using C standard terms.) The C standard
    uses terms like "object" and "byte" in a way that is unusual in the
    wider scope of computer science. But sometimes computer science courses
    use different terms, as do different programming languages and different
    parts of the world, and things change over time - often there is no
    single "standard CS" term, and often there is no fixed definition of a
    term commonly used in computer science. Many of the terms used in the C standard have the strong advantage of having specific definitions given
    in the standard itself.

    If in doubt, being a little extra explicit is better than being
    misunderstood!

    In the particular case of "constant", I think the root issue is that the
    word is overused. "integer constant" and "integer constant expression"
    are significantly different things in the C standards - it would seem
    logical to think that an "integer constant expression" evaluates to an "integer constant", but that is not the case. "const int x = 1;" does
    not define an "integer constant" or an "integer constant expression",
    while "constexpr int y = 1;" makes "y" and "integer constant expression"
    but not an "integer constant". Meanwhile, "Hello, world!" is a "string literal", not a "string constant".

    When C was young and fresh, there were far fewer constant things - and
    the terminology made sense. As more constant things (like "const" and
    then "constexpr") were added, it became less clear. C++ has called 123
    an "integer literal" for ages, and it makes sense for C to follow suit.

    I doubt if this is the start of a habit or pattern, however.



    It's noteworthy that the new C-standard draft is using that term;[*]
    I didn't know that, so also thanks also for that information.

    Janis

    [*] May we interpret that fact as C-standard terms might eventually
    converge to a more commonly accepted "beyond C standard" terminology?
    (I expect no answer. - It was just some pondering aloud.)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Oct 30 09:33:52 2026
    On 30/10/2026 00:29, Keith Thompson wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <11bvqbn$3g0tj$1@dont-email.me>,
    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    On 2026-10-28 21:50, Steven G. Kargl wrote:
    On Wed, 28 Oct 2026 17:59:19 -0700, Tim Rentsch wrote:
    "Steven G. Kargl" <sgk@REMOVEtroutmask.apl.washington.edu> writes:
    On Wed, 28 Oct 2026 16:39:00 -0700, Keith Thompson wrote:
    (Also, you misspelled "ROFL", and you don't need parentheses on the >>>>>>> return statement, particularly if you dislike fluff.)

    Yeah, I was laugh too hard while typing ;-)

    Parentheses is a habit from BSD kernel source file style guide.

    Now is a good time to start unlearning that habit.

    Why? What harm do the parentheses cause?

    They can lead to people thinking that return is a function, even if they >>> nominally know better.

    What? This is an incredibly weak argument.

    If someone thought that `return` was a function, then why
    wouldn't they think that `if` or `while` were also functions?
    Or `sizeof`, and so on?

    I agree that it's a bit of a weak argument, but I wouldn't call it
    incredibly weak.

    In my personal coding style, I try to avoid making things that are not function calls look like function calls. In a function call, there's no space between the function name and the left parenthesis. I don't use
    that style for anything other than function calls (or invocations of function-like macros). Not because I don't know return and sizeof are keywords, but because it's just a little bit easier to read the code
    if distinctions like that are clear.

    Examples:

    func(42); // function call, or maybe a macro invocation
    return 42; // not return(42); or even "return (42);
    if (cond) // not if(cond)
    sizeof (int) // not sizeof(int)
    sizeof obj // not sizeof(obj) or sizeof (obj)


    My preferences are similar, except that rather than distinguishing
    between functions and non-functions, I distinguish between statements
    and non-statements. So I write "sizeof(int)", rather than having a
    space - I see the operator as being more akin to a function call or
    macro invocation than to a statement.

    (I also write "sizeof(obj)", as that appears more natural to me than
    "sizeof obj", and more consistent - I do not like having the parentheses depend on whether the operand is a type or an expression.)

    The idea is to make the code just a little bit clearer and easier to
    read. If I see something that looks it would be a function call except
    that the prefix is a keyword, it's *very slightly* annoying.
    Parentheses on a return statement are allowed, but they're part of the expression, not part of the syntax of the return statement, and they're superfluous. I don't write `return (42);` for the same reason I don't
    write `x = (42);`.

    When you have a coding style that you have used consistently for a long
    time, code written in a different style always looks a bit clumsy and
    ugly, and is inevitably at least marginally harder to read. Some people
    do put spaces in weird places in their code, such as "if( x ){ ... }",
    or they don't use spaces at all, or apparently randomly add long runs of spaces. There's no accounting for taste!


    And of course *all* of these rules can be overridden by a coding
    standard or by the existing style of the surrounding code.

    Indeed.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From chine.bleu@3:633/10 to All on Fri Oct 30 02:39:20 2026
    Janis Papanagnou wrote:
    Would there be a problem with fixed-point arithmetic (that internally
    uses a few more than just two decimals for rounding etc.) but that is
    using basically a fixed-point representation?
    You could make a library for rational numbers (two integers) arithmetic
    where the denominator is a power of ten. If the CPU has decimal
    arithmetic, implement it in assembly.

    --
    Siri Seal of Disavowal #777-000. Disavowed. Denied. @
    NO KINGS For I desire mercy not sacrifice. /|\
    The Church of the Holey Apple .signature 5.5 / \
    of Discordian Mysteries. This post insults Islam. Mohamed

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Michael S@3:633/10 to All on Fri Oct 30 11:58:05 2026
    On Wed, 28 Oct 2026 16:05:06 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:
    On Wed, 28 Oct 2026 14:26:05 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    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.

    If you define objects as type float rather than double, do you have
    examples of code where using 0.1f rather than 0.1 makes a
    difference?

    One simple example: These two declarations result in identical code
    using gcc:

    float f = 0.1f;
    float f = 0.1;

    David almost certainly was talking about use of 0.1f in arithmetic expressions rather than in simple initialization.

    Agreed -- and I asked him for examples. (And no, didn't mean to
    suggest that there are no such examples.)

    And now that I've thought about it a bit more, here's a possible
    example:

    float f = rand(); // prevent optimization
    f *= 0.1;
    // f *= 0.1f;

    With 0.1, f is promoted to double before being multiplied by 0.1, and
    the result is converted to float. With 0.1f, double is not involved.
    And in the generated x86_64 assembly from gcc, I see cvtss2sd and
    cvtsd2ss when I use 0.1 that don't appear when I use 0.1f.

    Both expressions *might* yield the same result (and do in the small
    handful of cases I've checked), but it would take more analysis
    than I'm willing to perform to prove it in all cases.


    Since we're talking about single precision, analysis is not necessary.
    Any hypothesis can be easily tested by exhausting.
    In case of (float)(f * 0.1) == f * 0.1f, it fails for almost exactly one
    fifth of the numbers, including 1.00000011920928955f - the next float
    after 1.0f.


    I was too quick to assume that if a compiler sees 0.1 in an expression involving float operands, it can safely treat it as 0.1f. Since 0.1
    causes the usual arithmetic conversions to convert the other operand
    from float to double, I was very probably wrong.

    I can still imagine a compiler optimizing `f *= 0.1;` to use
    float arithmetic. I wonder if there are more clear-cut examples.


    I don't know what exactly is allowed by the Standard (that is, I know
    what's written, I don't know how peoples with lowyers attitude can
    interpret it), but will be extremely surprised if any "major" compiler
    is doing such optimization on IEEE-754 compliant platform in absence of non-compliance flags like fast-math.

    I'm assuming that FLT_EVAL_METHOD==0, meaning that float expressions
    are evaluated as float. If FLT_EVAL_METHOD==1, float expressions
    are evaluated to the range and precision of type double.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Oct 30 11:06:51 2026
    On 30/10/2026 10:39, chine.bleu wrote:
    Janis Papanagnou wrote:
    Would there be a problem with fixed-point arithmetic (that internally
    uses a few more than just two decimals for rounding etc.) but that is
    using basically a fixed-point representation?
    You could make a library for rational numbers (two integers) arithmetic where the denominator is a power of ten. If the CPU has decimal
    arithmetic, implement it in assembly.


    It does not make much sense to talk about a library for rational
    numbers, then restrict it to denominators with powers of ten. When you
    need exactly reproducible decimals, one option is to use a fixed number
    of places and then used scaled integers (a.k.a. fixed-point arithmetic)
    - basically hold your values in "long long int" types with a constant
    scale factor of 1'000'000, or similar.

    If you want to be able to handle different scale factors easily, then
    decimal floating point formats are appropriate. These are standardised
    in ISO/IEC 60559, and supported in C as _Decimal32, _Decimal64 and _Decimal128. The types are optional in C, but supported at least by gcc
    on "big" target systems. If the target hardware has appropriate
    instructions for them, the compiler should use that - that is vastly
    better than using assembly.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Fri Oct 30 10:58:35 2026
    In article <11c0kst$3pmvb$2@kst.eternal-september.org>,
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote: >cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <11bvqbn$3g0tj$1@dont-email.me>,
    James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
    [snip]
    They can lead to people thinking that return is a function, even if they >>>nominally know better.

    What? This is an incredibly weak argument.

    If someone thought that `return` was a function, then why
    wouldn't they think that `if` or `while` were also functions?
    Or `sizeof`, and so on?

    I agree that it's a bit of a weak argument, but I wouldn't call it
    incredibly weak.

    In my personal coding style, I try to avoid making things that are not >function calls look like function calls. In a function call, there's no >space between the function name and the left parenthesis. I don't use
    that style for anything other than function calls (or invocations of >function-like macros). Not because I don't know return and sizeof are >keywords, but because it's just a little bit easier to read the code
    if distinctions like that are clear.
    [snip examples]

    If I may paraphrase your argument, it's that you like to omit
    parentheses where unnecessary, or otherwise make operators
    visually distinct from function calls, so that while scanning
    code they stand out.

    But that is qualitatively different than what Kuyper said: "They
    can lead to people thinking that return is a function", which is
    ridiculous. Anyone even passingly familiar with the language
    knows that `return` in C is not a function, parentheses or no.

    [snip]
    The premise (at least for me) is not that someone would *think*
    that return is a function, but that making a return statement not
    look too much like a function call makes the code just a little
    bit easier to read.

    Perhaps; perhaps not. My day job involes working on a variant
    of System V Unix, which has a very strict style guide similar to
    (but different from...) FreeBSD's. That guide is descended from
    a document Bill Shannon put together at Sun for code in the
    older, BSD-derived SunOS 4.x operating system; a few years ago,
    another engineer and I took that document, cleaned it up,
    updated it to reflect existing practice, reorganized it a bit
    to logically flow better, and published it as a man page: https://illumos.org/man/7/style

    There are many things in there that I do not personally like;
    mandatory parentheses around the expression in a `return` are
    among them, but also the outright ban on `//` comments, macros
    over inline functions, and so on. I hold my nose and follow it
    because that's a requirement of the job. *Shrug*

    But sometimes I am very surprised at what my colleagues find
    unreadable; recently I wrote a rather large driver for an IP in
    our SoC complexes, and among the things that driver does are
    allocating physical address space to MMIO. The internal
    function one calls to do such things takes a number of
    arguments, including a pointer to an attributes structure, an
    address, a size, flags, and so on. I had neatly grouped the
    arguments onto lines so that, for example, the pointer to the
    attributes structure was on one line, then a line break and then
    the address and size together by themselves on the next line,
    etc. The reviewer (who's been working in this source base for
    several decades) found that very difficult to read and asked me
    to fill the lines as much as I could, up to the 80-column
    maximum (another limit I find silly); ironically, I found that
    much more difficult to read.

    The point is, "readability" can be subjective. What one person
    finds easy to read may not be so for another.

    And in the example that started this subthread, I probably wouldn't
    have mentioned the parentheses if the poster hadn't been complaining
    about "fluff".

    Yeah, that's fair. The poster seems unnecessarily combative in
    a weird way.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 14:07:38 2026
    On 2026-10-30 10:39, chine.bleu wrote:

    You could make a library for rational numbers (two integers) arithmetic where the denominator is a power of ten.

    Using rational numbers is of course an option. Though I don't recall
    to have seen common systems with support of rational arithmetic, and
    also languages with a rational numbers type seem not be too common. (Incidentally I've not long ago written such for a language that while inherently supporting even 'complex' numbers there's no 'rational'.
    Rationals are no biggie so could easily be provided through a library.)
    But I also think the fixed point approach is still just simpler and
    that's probably the reason for often having been used.

    If the CPU has decimal arithmetic, implement it in assembly.

    Well, the pocket calculators often had that and did exactly that.

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Oct 30 14:54:43 2026
    On 2026-10-30 09:11, David Brown wrote:
    On 30/10/2026 04:38, Janis Papanagnou wrote:
    On 2026-10-30 00:56, Keith Thompson wrote:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Note: my argumentation is based on questioning the existence of 'F'. >>>>> So I'd appreciate to hear of any enlightening application cases, ones >>>>> that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    For now.˙ In the latest C2y draft, they're called literals.

    Proposal:˙˙˙˙˙˙ https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3189.htm
    Draft standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3998.pdf

    (You've said before that you dislike this change.)

    In any case, the term "literal" is unambiguous, even if it's not
    currently used by the C standard.

    Thanks for answering him. (As I'm yet again ignoring him I wouldn't
    have noticed his statement.)

    For other readers I remind that I'm not necessarily using C-standard
    terms if there's terms common in CS existing that either appear more
    appropriately describing things, or if I'm generalizing facts beyond
    "C".

    The preference should be to use the C standard terms in this group - or

    Like there's no CLC coding style (as recently demanded and rebutted)
    it's also, IMO, presumptuous to demand posters to use terms defined
    in the C-standards documents. Moreover, as I recently learned, even
    the standard-C documents seem to adjust their terminology.

    As I explained already, I'm using the terms that appear to me to be
    most appropriate to describe things. In cases where there's multiple
    options I'm gladly using the terms preferred in the C-standard docs,
    given that I know them.

    I certainly consider it presumptuous to demand from posters to read
    (all or every new version of) the C-standard to talk about "C".

    to add brief comments for clarity.˙ (Sometimes it is also worth adding comments for clarity even when using C standard terms.)˙ The C standard
    uses terms like "object" and "byte" in a way that is unusual in the
    wider scope of computer science.˙ But sometimes computer science courses
    use different terms, as do different programming languages and different parts of the world, and things change over time - often there is no
    single "standard CS" term, and often there is no fixed definition of a
    term commonly used in computer science.

    That's all correct.

    As I mentioned elsewhere already - I think also in a reply to a post
    of yours, about the same topic - I'm gladly explaining (if necessary)
    not only every word in my posts that are unclear to you but also the
    implied semantics if necessary.

    (Mind that, as opposed to you and some others, while you may do that,
    I'm *not* discussing the _C-standard_ here. You should make yourself
    clear that there's a difference between talking about all aspects of
    the language or exchange specifically about the formal aspects of "C".
    What makes perfectly sense for the former group is, to say the least,
    arguable for the general, non-specialized disputants.)

    Many of the terms used in the C
    standard have the strong advantage of having specific definitions given
    in the standard itself.

    Fine.


    If in doubt, being a little extra explicit is better than being misunderstood!

    No doubt.


    In the particular case of "constant", I think the root issue is that the word is overused.˙ "integer constant" and "integer constant expression"

    I think in the post you are referring to I described a different thing;
    I spoke about a constant literal. And the (IMO unnecessary) dispute had
    been about "literal" not about "constant". - And we heard that "literal"
    is even the new term used in the (draft) C-standard!

    [snip digressions about "integer constant" and "constant expressions"]
    [snip more digressions on early C-"constants"]

    [...]˙ C++ has called 123
    an "integer literal" for ages, and it makes sense for C to follow suit.

    Yes, and I agree with that choice. (I'm using the word "literal" for all programming languages if I want to talk about literals.)


    I doubt if this is the start of a habit or pattern, however.

    I think it's pointless to make guesses. (I'm certainly continuing to
    use those terms that I think are best fitting. And if you (or others)
    have problems understanding them I'm gladly explaining them, as said. Especially since I think the time spent on an explanation of a good
    term is much better spent than the time wasted for a discussion like
    the one you restarted here yet another time.)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Fri Oct 30 13:55:09 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-10-30 01:50, Lawrence D?Oliveiro wrote:
    [...]

    How would you do calculations involving compound interest payments
    without floating-point arithmetic? And why would you want to?

    Because what gets in and what comes out is just exact fixed point?
    And you need more an exact transformation to and from the internal
    values? And exact representation with BCD more than binary floating
    point? (Mind the 0.10 issue!) - I think there was a reason why with
    COBOL, the COmmon Business Oriented Language, there was - at least >historically - fixed-point arithmetic used for the financial sector?
    (But please CMIIW.)

    All the early electrodata/burroughs business computers (Datatron 220,
    Burroughs B300, Burroughs B3500) used fixed point BCD representations
    for business applications and the COBOL compiler.


    Would there be a problem with fixed-point arithmetic (that internally
    uses a few more than just two decimals for rounding etc.) but that is
    using basically a fixed-point representation?

    And we saw in some post this hilarious sample of an (Amazon?) bill.
    (Not that this couldn't have been fixed even/also with FP-arithmetic.)

    Simply using %8.2f would have been sufficient, but modern programmers
    don't like printf formatting, apparently.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Oct 30 15:25:33 2026
    On 30/10/2026 14:54, Janis Papanagnou wrote:
    On 2026-10-30 09:11, David Brown wrote:
    On 30/10/2026 04:38, Janis Papanagnou wrote:
    On 2026-10-30 00:56, Keith Thompson wrote:
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    Note: my argumentation is based on questioning the existence of 'F'. >>>>>> So I'd appreciate to hear of any enlightening application cases, ones >>>>>> that would be impossible when 'F' in literals wouldn't be present.

    In C the word is constants, not literals.

    For now.˙ In the latest C2y draft, they're called literals.

    Proposal:˙˙˙˙˙˙ https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3189.htm
    Draft standard: https://www.open-std.org/jtc1/sc22/wg14/www/docs/
    n3998.pdf

    (You've said before that you dislike this change.)

    In any case, the term "literal" is unambiguous, even if it's not
    currently used by the C standard.

    Thanks for answering him. (As I'm yet again ignoring him I wouldn't
    have noticed his statement.)

    For other readers I remind that I'm not necessarily using C-standard
    terms if there's terms common in CS existing that either appear more
    appropriately describing things, or if I'm generalizing facts beyond
    "C".

    The preference should be to use the C standard terms in this group - or

    Like there's no CLC coding style (as recently demanded and rebutted)

    Agreed.

    it's also, IMO, presumptuous to demand posters to use terms defined
    in the C-standards documents.

    "Demand" is far too strong a word. It is not presumptuous or onerous to /prefer/ standard terms for a given language in a language-specific
    Usenet group. Discussing what is and is not supported and required by
    the C standards is par for the course in comp.lang.c, and understanding
    the standard terms is an important part of that. We don't need to be obsessive about it unless it is an important detail of the issue being discussed, as long things are clear enough.

    Moreover, as I recently learned, even
    the standard-C documents seem to adjust their terminology.

    This has happened /once/, in the space of about 40 years. It's not as
    if they change terms on a regular basis!


    As I explained already, I'm using the terms that appear to me to be
    most appropriate to describe things. In cases where there's multiple
    options I'm gladly using the terms preferred in the C-standard docs,
    given that I know them.

    Fair enough. The important thing, as I see it, is that people in a
    discussion know what each other is talking about.


    I certainly consider it presumptuous to demand from posters to read
    (all or every new version of) the C-standard to talk about "C".

    I would certainly agree on that, and I don't think anyone has made such demands.


    to add brief comments for clarity.˙ (Sometimes it is also worth adding
    comments for clarity even when using C standard terms.)˙ The C
    standard uses terms like "object" and "byte" in a way that is unusual
    in the wider scope of computer science.˙ But sometimes computer
    science courses use different terms, as do different programming
    languages and different parts of the world, and things change over
    time - often there is no single "standard CS" term, and often there is
    no fixed definition of a term commonly used in computer science.

    That's all correct.

    As I mentioned elsewhere already - I think also in a reply to a post
    of yours, about the same topic - I'm gladly explaining (if necessary)
    not only every word in my posts that are unclear to you but also the
    implied semantics if necessary.

    You tend to write very clearly - it's a rarity that your posts are misunderstood, I think.


    (Mind that, as opposed to you and some others, while you may do that,
    I'm *not* discussing the _C-standard_ here. You should make yourself
    clear that there's a difference between talking about all aspects of
    the language or exchange specifically about the formal aspects of "C".
    What makes perfectly sense for the former group is, to say the least, arguable for the general, non-specialized disputants.)

    It is certainly the case that there are times when detailed
    consideration of the exact language and terms of the standards are
    important to the discussion, and plenty of times when they are not. I
    have nothing against loser language when loser language is easier to use
    for the point at hand.


    Many of the terms used in the C standard have the strong advantage of
    having specific definitions given in the standard itself.

    Fine.


    If in doubt, being a little extra explicit is better than being
    misunderstood!

    No doubt.


    In the particular case of "constant", I think the root issue is that
    the word is overused.˙ "integer constant" and "integer constant
    expression"

    I think in the post you are referring to I described a different thing;
    I spoke about a constant literal. And the (IMO unnecessary) dispute had
    been about "literal" not about "constant". - And we heard that "literal"
    is even the new term used in the (draft) C-standard!


    I am not sure if I was referring to a particular post - and I am not
    sure if there was a "dispute" at all (unless you count Tim's post).
    It's okay for someone to comment on the term used in the C standard
    without it implying that your post was wrong to use a different term.

    In this particular case, I personally prefer "literal" to "constant".
    It's the term used in the C2y draft, it is also used in the C++
    standards, and consistent with current C standards use of "string
    literals" and "compound literals". But it can also be useful for people
    to know that "integer constant" is the term for 123 in current C, not
    "integer literal". One use of that knowledge is if people want to look
    up more information on quality reference sites (like cppreference.com)
    or in the standards themselves - it's easier if you know the standard
    terms. If you want to know the exact rules for "integer constants", and
    try to search the standards for "integer literal", you'll find no hits
    except, bizarrely, a mention of "binary integer literals" in the list of changes to standards versions.

    [snip digressions about "integer constant" and "constant expressions"]
    [snip more digressions on early C-"constants"]

    [...]˙ C++ has called 123 an "integer literal" for ages, and it makes
    sense for C to follow suit.

    Yes, and I agree with that choice. (I'm using the word "literal" for all programming languages if I want to talk about literals.)


    I doubt if this is the start of a habit or pattern, however.

    I think it's pointless to make guesses. (I'm certainly continuing to
    use those terms that I think are best fitting. And if you (or others)
    have problems understanding them I'm gladly explaining them, as said. Especially since I think the time spent on an explanation of a good
    term is much better spent than the time wasted for a discussion like
    the one you restarted here yet another time.)

    Janis



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Fri Oct 30 14:45:03 2026
    In article <11c29cu$alhk$1@dont-email.me>,
    David Brown <david.brown@hesbynett.no> wrote:
    On 30/10/2026 14:54, Janis Papanagnou wrote:
    [snip]
    it's also, IMO, presumptuous to demand posters to use terms defined
    in the C-standards documents.

    "Demand" is far too strong a word. It is not presumptuous or onerous to >/prefer/ standard terms for a given language in a language-specific
    Usenet group. Discussing what is and is not supported and required by
    the C standards is par for the course in comp.lang.c, and understanding
    the standard terms is an important part of that. We don't need to be >obsessive about it unless it is an important detail of the issue being >discussed, as long things are clear enough.

    I agree with both of you: mutual understanding should be the
    goal, and while a preference for the language used in the
    standard is certainly fine, there are unfortunately several
    examples around here of the type of person who favors pedantic
    attention to detail over that kind understanding.

    My own view is that this is not useful, and actively harmful.
    It certainly does not paint those posters in a positive light,
    as they appear to be more concerned with the minutia of the
    standard's phrasing than they are with its content, and are
    wholy unconcerned with usefully conveying anything of substance
    to a reader. Fixation on minor details feels like an excuse to
    find fault with a poster, then used to refrain from deeper
    engagement with whatever point they are raising, even if it is
    well considered and thoughtful. That's not holding conversation
    to a standard of quality; it is simplistic and reductive.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From chine.bleu@3:633/10 to All on Fri Oct 30 07:45:59 2026
    scott@slp53.sl.home (Scott Lurndal) wrote:
    All the early electrodata/burroughs business computers (Datatron 220, Burroughs B300, Burroughs B3500) used fixed point BCD representations
    for business applications and the COBOL compiler.

    STAR-100 supported 65535 digit decimal.

    --
    Siri Seal of Disavowal #777-000. Disavowed. Denied. @
    NO KINGS For I desire mercy not sacrifice. /|\
    The Church of the Holey Apple .signature 5.5 / \
    of Discordian Mysteries. This post insults Islam. Mohamed

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Fri Oct 30 11:12:45 2026
    On 10/30/2026 3:06 AM, David Brown wrote:
    On 30/10/2026 10:39, chine.bleu wrote:
    Janis Papanagnou wrote:
    Would there be a problem with fixed-point arithmetic (that internally
    uses a few more than just two decimals for rounding etc.) but that is
    using basically a fixed-point representation?
    You could make a library for rational numbers (two integers)
    arithmetic where the denominator is a power of ten. If the CPU has
    decimal arithmetic, implement it in assembly.


    It does not make much sense to talk about a library for rational
    numbers, then restrict it to denominators with powers of ten.˙ When you
    need exactly reproducible decimals, one option is to use a fixed number
    of places and then used scaled integers (a.k.a. fixed-point arithmetic)
    - basically hold your values in "long long int" types with a constant
    scale factor of 1'000'000, or similar.

    If you want to be able to handle different scale factors easily, then decimal floating point formats are appropriate.˙ These are standardised
    in ISO/IEC 60559, and supported in C as _Decimal32, _Decimal64 and _Decimal128.˙ The types are optional in C, but supported at least by gcc
    on "big" target systems.˙ If the target hardware has appropriate instructions for them, the compiler should use that - that is vastly
    better than using assembly.


    Try to gain a rational that fits for a given precision for a target
    real? Convergents of continued fractions?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Fri Oct 30 12:02:33 2026
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    It is certainly the case that there are times when detailed
    consideration of the exact language and terms of the standards are
    important to the discussion, and plenty of times when they are not. I
    have nothing against loser language when loser language is easier to
    use for the point at hand.
    [...]

    That sounded a lot harsher than you intended until I realized you had misspelled "looser".

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Oct 30 21:01:58 2026
    On 30/10/2026 20:02, Keith Thompson wrote:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    It is certainly the case that there are times when detailed
    consideration of the exact language and terms of the standards are
    important to the discussion, and plenty of times when they are not. I
    have nothing against loser language when loser language is easier to
    use for the point at hand.
    [...]

    That sounded a lot harsher than you intended until I realized you had misspelled "looser".


    Oops - yes, it was a misspelling. Thanks for catching it, as I agree it sounded really bad! (My apologies to Janis if he felt I was somehow
    insulting him - it was not at all intentional.)

    Little red wiggles under misspelt words are great in general, but don't
    help much when the misspelling is also a valid word.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lynn McGuire@3:633/10 to All on Fri Oct 30 22:00:23 2026
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some
    more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily. It will always come back to bite you.

    Lynn


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lynn McGuire@3:633/10 to All on Fri Oct 30 22:01:06 2026
    On 10/30/2026 10:00 PM, Lynn McGuire wrote:
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it
    give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily.˙ It will always come back to bite you.

    Lynn

    Tell the AI to stop the nonsense.

    Lynn


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paul@3:633/10 to All on Sat Oct 31 02:16:20 2026
    On Fri, 10/30/2026 11:01 PM, Lynn McGuire wrote:
    On 10/30/2026 10:00 PM, Lynn McGuire wrote:
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily.˙ It will always come back to bite you.

    Lynn

    Tell the AI to stop the nonsense.

    Lynn


    You can do that. The trick to being a vibe coder,
    is knowing what to put in the prompt.

    And this is why, even if you have "negative interest" in LLM-AI,
    you should at least do enough experiments to detect their dimensionality
    (their linear thinking when used in isolation and without
    a harness).

    There is a big big difference, between what Fir is doing,
    and what professionals right now are doing.

    [Teaser]

    https://www.theregister.com/devops/2026/09/18/microsoft-agentically-ports-copilot-runtime-to-rust-for-120k/5297549

    [Details]

    https://github.blog/ai-and-ml/generative-ai/migrating-the-github-copilot-runtime-to-rust-using-copilot/

    On the one hand, the $120,000 worth of tokens, seems expensive. But
    on the other hand, the staff it would have taken to do the equivalent
    would not have been free.

    Even an expert, he still made a mistake in corralling the machines
    and preventing them from "cheating". The non-determinism means
    you can never stop learning about what guard statements to add.

    The code review is still the bottleneck, and lots of operations outside
    of Microsoft, do not see the gains of the "all-in" "experimental"
    approach shown in the above.

    Even if you're not interested in such things, you have to track
    the capabilities, to understand how your ass is going to get kicked.
    For example, you may have a superior product to the upstarts vibe-coding
    an equivalent. But now you are going to have to do extra marketing
    to ensure your existing customers "do not run away".

    The getcraft site has been making (what it claims are) equivalents
    to commercial applications like the Adobe suite and Microsoft Office.
    By no means are these equivalent, not even close. But what the
    existence of these things do, is they lead to customers "testing
    all sorts of shit" and diluting a lot of careful work you might
    have done to get where you are. I tested a couple of those getcraft in
    a VM, and there was "excessive CPU usage". The engine is Electron
    (for cross-platform usage).

    Paul



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sat Oct 31 08:30:32 2026
    Paul pisze:
    On Fri, 10/30/2026 11:01 PM, Lynn McGuire wrote:
    On 10/30/2026 10:00 PM, Lynn McGuire wrote:
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and >>>> yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily.˙ It will always come back to bite you.

    Lynn

    Tell the AI to stop the nonsense.

    Lynn


    You can do that. The trick to being a vibe coder,
    is knowing what to put in the prompt.

    And this is why, even if you have "negative interest" in LLM-AI,
    you should at least do enough experiments to detect their dimensionality (their linear thinking when used in isolation and without
    a harness).

    There is a big big difference, between what Fir is doing,
    and what professionals right now are doing.

    [Teaser]

    https://www.theregister.com/devops/2026/09/18/microsoft-agentically-ports-copilot-runtime-to-rust-for-120k/5297549

    [Details]

    https://github.blog/ai-and-ml/generative-ai/migrating-the-github-copilot-runtime-to-rust-using-copilot/

    On the one hand, the $120,000 worth of tokens, seems expensive. But
    on the other hand, the staff it would have taken to do the equivalent
    would not have been free.

    Even an expert, he still made a mistake in corralling the machines
    and preventing them from "cheating". The non-determinism means
    you can never stop learning about what guard statements to add.

    The code review is still the bottleneck, and lots of operations outside
    of Microsoft, do not see the gains of the "all-in" "experimental"
    approach shown in the above.

    Even if you're not interested in such things, you have to track
    the capabilities, to understand how your ass is going to get kicked.
    For example, you may have a superior product to the upstarts vibe-coding
    an equivalent. But now you are going to have to do extra marketing
    to ensure your existing customers "do not run away".

    The getcraft site has been making (what it claims are) equivalents
    to commercial applications like the Adobe suite and Microsoft Office.
    By no means are these equivalent, not even close. But what the
    existence of these things do, is they lead to customers "testing
    all sorts of shit" and diluting a lot of careful work you might
    have done to get where you are. I tested a couple of those getcraft in
    a VM, and there was "excessive CPU usage". The engine is Electron
    (for cross-platform usage).

    Paul

    i wouldnt say i do vibe coding..i do normal coding wit a help of ai assistant..vibe coding may be something different than i do

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Waldek Hebisch@3:633/10 to All on Sat Oct 31 12:18:21 2026
    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, so `0.1f` "unquestionably"* better.

    * "unquestionably" in this group meaning that somebody will
    disagree.

    --
    Waldek Hebisch

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Sat Oct 31 13:16:43 2026
    On 10/31/2026 12:30 AM, fir wrote:
    Paul pisze:
    On Fri, 10/30/2026 11:01 PM, Lynn McGuire wrote:
    On 10/30/2026 10:00 PM, Lynn McGuire wrote:
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the and >>>>> yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may
    it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies
    some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily.˙ It will always come back to bite you. >>>>
    Lynn

    Tell the AI to stop the nonsense.

    Lynn


    You can do that. The trick to being a vibe coder,
    is knowing what to put in the prompt.

    And this is why, even if you have "negative interest" in LLM-AI,
    you should at least do enough experiments to detect their dimensionality
    (their linear thinking when used in isolation and without
    a harness).

    There is a big big difference, between what Fir is doing,
    and what professionals right now are doing.

    ˙˙ [Teaser]

    ˙˙˙ https://www.theregister.com/devops/2026/09/18/microsoft-
    agentically-ports-copilot-runtime-to-rust-for-120k/5297549

    ˙˙ [Details]

    ˙˙˙ https://github.blog/ai-and-ml/generative-ai/migrating-the-github-
    copilot-runtime-to-rust-using-copilot/

    On the one hand, the $120,000 worth of tokens, seems expensive. But
    on the other hand, the staff it would have taken to do the equivalent
    would not have been free.

    Even an expert, he still made a mistake in corralling the machines
    and preventing them from "cheating". The non-determinism means
    you can never stop learning about what guard statements to add.

    The code review is still the bottleneck, and lots of operations outside
    of Microsoft, do not see the gains of the "all-in" "experimental"
    approach shown in the above.

    Even if you're not interested in such things, you have to track
    the capabilities, to understand how your ass is going to get kicked.
    For example, you may have a superior product to the upstarts vibe-coding
    an equivalent. But now you are going to have to do extra marketing
    to ensure your existing customers "do not run away".

    The getcraft site has been making (what it claims are) equivalents
    to commercial applications like the Adobe suite and Microsoft Office.
    By no means are these equivalent, not even close. But what the
    existence of these things do, is they lead to customers "testing
    all sorts of shit" and diluting a lot of careful work you might
    have done to get where you are. I tested a couple of those getcraft in
    a VM, and there was "excessive CPU usage". The engine is Electron
    (for cross-platform usage).

    ˙˙˙ Paul

    i wouldnt say i do˙ vibe coding..i do normal coding wit a help of ai assistant..vibe coding may be something different than i do

    At least you don't let do all of your coding.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sat Oct 31 21:23:30 2026
    Chris M. Thomasson pisze:
    On 10/31/2026 12:30 AM, fir wrote:
    Paul pisze:
    On Fri, 10/30/2026 11:01 PM, Lynn McGuire wrote:
    On 10/30/2026 10:00 PM, Lynn McGuire wrote:
    On 10/27/2026 5:53 AM, fir wrote:
    if ai generates me some functions it puts everywhere this f at the >>>>>> and
    yet it add zeros so instead of .1 i got 0.1f

    and i obviously dont like it

    i write hvever some codes when i need speed so the question is may >>>>>> it give some difference?

    i mean .1 maybe can be treated as doube constants so mabe occupies >>>>>> some more memory (?) or uses some casting in coplutations (?)


    i doubt it probably it makes difference but im strictly not sure

    Never give up precision easily.˙ It will always come back to bite you. >>>>>
    Lynn

    Tell the AI to stop the nonsense.

    Lynn


    You can do that. The trick to being a vibe coder,
    is knowing what to put in the prompt.

    And this is why, even if you have "negative interest" in LLM-AI,
    you should at least do enough experiments to detect their dimensionality >>> (their linear thinking when used in isolation and without
    a harness).

    There is a big big difference, between what Fir is doing,
    and what professionals right now are doing.

    ˙˙ [Teaser]

    ˙˙˙ https://www.theregister.com/devops/2026/09/18/microsoft-
    agentically-ports-copilot-runtime-to-rust-for-120k/5297549

    ˙˙ [Details]

    ˙˙˙ https://github.blog/ai-and-ml/generative-ai/migrating-the-github-
    copilot-runtime-to-rust-using-copilot/

    On the one hand, the $120,000 worth of tokens, seems expensive. But
    on the other hand, the staff it would have taken to do the equivalent
    would not have been free.

    Even an expert, he still made a mistake in corralling the machines
    and preventing them from "cheating". The non-determinism means
    you can never stop learning about what guard statements to add.

    The code review is still the bottleneck, and lots of operations outside
    of Microsoft, do not see the gains of the "all-in" "experimental"
    approach shown in the above.

    Even if you're not interested in such things, you have to track
    the capabilities, to understand how your ass is going to get kicked.
    For example, you may have a superior product to the upstarts vibe-coding >>> an equivalent. But now you are going to have to do extra marketing
    to ensure your existing customers "do not run away".

    The getcraft site has been making (what it claims are) equivalents
    to commercial applications like the Adobe suite and Microsoft Office.
    By no means are these equivalent, not even close. But what the
    existence of these things do, is they lead to customers "testing
    all sorts of shit" and diluting a lot of careful work you might
    have done to get where you are. I tested a couple of those getcraft in
    a VM, and there was "excessive CPU usage". The engine is Electron
    (for cross-platform usage).

    ˙˙˙ Paul

    i wouldnt say i do˙ vibe coding..i do normal coding wit a help of ai
    assistant..vibe coding may be something different than i do

    At least you don't let do all of your coding.

    this free model i use wouldnt be able to do that i think

    though sometimes i make an error giving it 20 small task instead of
    saying "do all that task"..im afraid of uveruse it..but its not good
    becouse of it i sometimes still dwell in boring editing work

    it is all very interesting thought, its really interesting 'adventure'


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Sun Nov 1 17:15:23 2026
    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.
    Yes, that's hard to believe.

    See <https://stackoverflow.com/questions/2781244/is-return-an-operator-or-a-function>

    The following were all posted to comp.lang.c:

    On 1997-03-05, Raymond J Tompkins posted a message whose title was
    "Return() function, is it???" which starts out "I'm trying to use the
    return() function ...".

    On 2003-03-15, Ankur Vyas posted a message whose title was "return
    function".

    On 2010-08-28, Tony Clough wrote that
    "One possible problem with C as compared to other languages like Perl or
    Shell is that function calls require parentheses which leads to
    cluttered code. (But there are some funny exceptions in the standard
    library though, eg return and size_of do not need parentheses)"

    It's not, by any means, a common misconception, but it does occur.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Sun Nov 1 23:29:33 2026
    On Sun, 1 Nov 2026 17:15:23 -0500, James Kuyper wrote:

    On 2010-08-28, Tony Clough wrote that "One possible problem with C
    as compared to other languages like Perl or Shell is that function
    calls require parentheses which leads to cluttered code. (But there
    are some funny exceptions in the standard library though, eg return
    and size_of do not need parentheses)"

    sizeof does require parentheses if you pass it a type, not for an
    expression (except for the usual precedence reasons).

    Not sure why that is ...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Sun Nov 1 16:03:41 2026
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    On Sun, 1 Nov 2026 17:15:23 -0500, James Kuyper wrote:
    On 2010-08-28, Tony Clough wrote that "One possible problem with C
    as compared to other languages like Perl or Shell is that function
    calls require parentheses which leads to cluttered code. (But there
    are some funny exceptions in the standard library though, eg return
    and size_of do not need parentheses)"

    sizeof does require parentheses if you pass it a type, not for an
    expression (except for the usual precedence reasons).

    Not sure why that is ...

    Because if parentheses were not required around the type name, it would
    result in ambiguities. (I don't have an example off the top of my
    head.)

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From James Kuyper@3:633/10 to All on Sun Nov 1 22:37:26 2026
    On 2026-10-30 05:58, Michael S wrote:
    On Wed, 28 Oct 2026 16:05:06 -0700
    Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
    I was too quick to assume that if a compiler sees 0.1 in an expression
    involving float operands, it can safely treat it as 0.1f. Since 0.1
    causes the usual arithmetic conversions to convert the other operand
    from float to double, I was very probably wrong.

    I can still imagine a compiler optimizing `f *= 0.1;` to use
    float arithmetic. I wonder if there are more clear-cut examples.


    I don't know what exactly is allowed by the Standard (that is, I know
    what's written, I don't know how peoples with lowyers attitude can
    interpret it), ...
    "The accuracy of the floating-point operations (+, -, *, /) and of most
    of the library functions in <math.h> and <complex.h> that return
    floating-point results is implementation-defined, as is the accuracy of
    the conversion between floating-point internal representations and
    string representations performed by the library functions in <stdio.h>, <stdlib.h>, and <wchar.h>. The implementation may state that the
    accuracy is unknown." (n3998 5.3.5.33.p20)

    Note that this allows sufficient inaccuracy that the expression

    LDBL_MAX - LDBL_MIN < LDBL_MIN - LDBL_MAX

    is permitted to evaluate to 1, so long as you either document how bad
    the accuracy is, or state that it's unknown. Unless something else
    imposes stronger requirements, C floating point is almost completely
    useless.

    ... but will be extremely surprised if any "major" compiler
    is doing such optimization on IEEE-754 compliant platform in absence of non-compliance flags like fast-math.
    One way to get stronger requirements is to require that
    __STDC_IEC_60559_BFP__ be pre#defined, which mandates conformance with
    Annex F, which essentially requires conformance to ISO/IEC 60559 ==
    IEEE-754.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Mon Nov 2 08:50:17 2026
    On 02/11/2026 01:03, Keith Thompson wrote:
    Lawrence D?Oliveiro <ldo@nz.invalid> writes:
    On Sun, 1 Nov 2026 17:15:23 -0500, James Kuyper wrote:
    On 2010-08-28, Tony Clough wrote that "One possible problem with C
    as compared to other languages like Perl or Shell is that function
    calls require parentheses which leads to cluttered code. (But there
    are some funny exceptions in the standard library though, eg return
    and size_of do not need parentheses)"

    sizeof does require parentheses if you pass it a type, not for an
    expression (except for the usual precedence reasons).

    Not sure why that is ...

    Because if parentheses were not required around the type name, it would result in ambiguities. (I don't have an example off the top of my
    head.)


    Perhaps

    x = sizeof(int *) - 1
    vs
    x = sizeof int * - 1

    ?

    The later could certainly be misunderstood by someone reading it, but I
    don't know if it would have been ambiguous in the language if
    parentheses had not been required for "sizeof(type)".


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 2 18:22:23 2026
    Am 27.10.2026 um 18:50 schrieb fir:

    but the question is: can using .1 instead of 0.1f make me any harm in
    code? ...
    You might get a warning because of the precision loss.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 2 18:25:43 2026
    Am 27.10.2026 um 19:40 schrieb Scott Lurndal:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    If you have a proper fp to decimal runtime function this actually
    won't happen. That's while numbers which would result in the above
    output would always be rounded correctly. That's safe since you'd
    need billions of computations that wouldn't result to such results
    by accident.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Mon Nov 2 17:31:47 2026
    Bonita Montero <Bonita.Montero@gmail.com> writes:
    Am 27.10.2026 um 19:40 schrieb Scott Lurndal:

    Total
    75.71000000000001 USD

    Appears they may be using FP instead of integer fixed point arithmetic
    for pricing.

    If you have a proper fp to decimal runtime function this actually
    won't happen. That's while numbers which would result in the above
    output would always be rounded correctly. That's safe since you'd
    need billions of computations that wouldn't result to such results
    by accident.


    There's no reason to use FP at all in this application.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Mon Nov 2 20:20:27 2026
    On Mon, 2 Nov 2026 18:25:43 +0100, Bonita Montero wrote:

    If you have a proper fp to decimal runtime function this actually
    won't happen.

    Or if you use a decimal rather than binary number representation in
    the first place.

    (Note this orthogonal to the issue of fixed-point versus
    floating-point.)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Tue Nov 3 08:45:44 2026
    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.

    Yes, that's hard to believe.

    See

    No. Cherry picking a few absurd examples from 20+ years of
    USENET, probably some of which are easily explained by
    non-native English speakers unxerstanding the construct but
    simply using the wrong nomenclature, really does not prove
    anything. You could probably find examples of new programmers
    being similarly confused by `while` and `if`, which I had
    mentioned previously.

    It's not, by any means, a common misconception, but it does occur.

    Not with any significant frequency or durability. To the extent
    that it ever happens, it is not the sort of error that survives
    even casual experience.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Tue Nov 3 18:25:53 2026
    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.

    We can eliminate returns from a program by passing a context
    argument to each function: the return continuation. The places
    where the function returns become tail calls to the continuation.

    The transformation of a program to continuation passing style ("CPS transformation") can be done by a compiler, allowing a program in a
    language in which ordinary function returning appears to work under the
    hood by returns achieved by a function call.

    How it works is that all the code that would take place in the
    caller after a function returns is bundled into a lambda body,
    and the lambda is passed as the continuation argument.

    (This is now actually very familiar to youngsters who work in web front
    end and know about "async" functions. In that paradigm, a kind of
    continuation system appears whereby the computation we'd like to do from
    now on, but only after some event is received, is farmed out to a
    lambda.)

    Famously, (to tie this back to C somehow), Chicken Scheme implements continuation over the native stack in a particular way. Chicken Scheme
    code is translated to C code, and that C code never returns from its
    functions. It always passes a lambda to the callee. Lambdas capture
    their context on the stack. Because nothing ever returns, pointers and
    other objects on the stack nicely persist: local variables don't die
    after a function returns because it's compiled to a C function that
    returns by calling a continuation. When the stack hits a certain limit,
    it is rewound back to the top. At that time, all the objects in the
    stack that are still live are identified and moved to the heap. I think,
    even character strings in their entirety (the actual array) are
    bump-allocated on the stack, and so have to be memmoved to the heap when
    the stack rewinds, so the stack acts as a nursery for new objects.


    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Thu Nov 5 06:31:59 2026
    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?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Waldek Hebisch@3:633/10 to All on Thu Nov 5 22:07:10 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    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?

    Going via doubles number in the C source will be rounded twice,
    first time to a double, then the result of first runding will
    be rounded second time. Each rounding step introduces some
    error. Resonable heuristic says that errors may be close to
    maximal possible and may add. So error may be bigger than
    from single rounding.

    If you do not want to belive in the heuristic above, consider
    IEEE arthmetic and two consequtive single precisin numbers
    a and b. Next, take double c in the middle of the interval
    between a nad b. According to IEEE "round to even" rule this
    double will be rounded to one of the singles above, say a. Take
    source number d that rounds to c, but is on the side corresponding
    to b. Going via double will produce a as the result. Directly
    rounding to single will produce b. It is clear that b is
    closer to d than a, so double rounding in this case indeed
    produces more error, that is less accuracy.

    --
    Waldek Hebisch

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)