• Re: why is there not a ipow version of pow?

    From Lawrence D?Oliveiro@3:633/10 to All on Fri Aug 14 02:50:12 2026
    On Wed, 12 Aug 2026 18:40:37 +0200, Bonita Montero wrote:

    Nice fact: clang++ and g++ are *much* faster than MSVC with my code.
    I asked my self why is that and I had a look at the compiled code. I
    do a "b * e / b == b" check. MSVC uses a division for that. g++ and
    clang++ just check the overflow flag after doing the multiplication.

    Clever. :)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Fri Aug 14 10:58:03 2026
    On 14/08/2026 8:07 AM, Lynn McGuire wrote:
    On 8/13/2026 4:19 AM, Johann 'Myrkraverk' Oskarsson wrote:
    On 11/08/2026 4:01 PM, Lynn McGuire wrote:
    Why is there not a ipow version of pow?

    ipow would return an int instead of a double.ÿ Or a long long int.

    Thanks,
    Lynn


    Dear Lynn,

    I can't speak for the ISO C committee, but my guess is the lack of a
    multi precision library in the standard.ÿ If I remember Tom St Denis'
    book correctly, implementing an ipow() with such a library is /trivial/
    for some version of trivial.ÿ I just don't remember if such a function
    is included in his.

    In any case, I don't think an ipow() is all that useful unless there is
    a multiprecision type to return the value.ÿ Do you disagree with that?

    I would rather see a standard user interface toolkit for C++ first.

    Fair enough. I come at this discussion from comp.lang.c, and as such,
    don't care what the C++ standards committee does.


    https://wxwidgets.org/ is close but I have yet to try it out.

    I just treat IUP as an /industry standard/ interface toolkit for C.

    https://iup.sourceforge.net/

    And I believe that would require a different standards committee than
    -- what was it? WG14 -- to include in the ISO standards collection, as
    it's still targetting C89 if I'm not mistaken, and doesn't keep up with
    WG14 at all.

    Perhaps just best to standardize it with A.N.S.I. in the United States,
    if at all? I admit ignorance on how much paperwork that is, and I'd
    certainly include PUC Rio in such discussions, somehow. Even if they're
    also not in the United States.


    Best wishes, and happy interfacing with IUP!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Fri Aug 14 11:22:25 2026
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s
    all down to dynamic range. Logs and exponentials by their nature are
    liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do
    not cater for this. Whereas with floating-point -- well, it?s there in
    the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe even a
    128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 14 00:58:49 2026
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals are
    moving between the four phases of matter that we support: vapor,
    hydrocarbon liquid, aqueous liquid, and solids, based on temperature
    and pressure.ÿ The tables are incredibly non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.

    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 Aug 14 01:00:40 2026
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s
    all down to dynamic range. Logs and exponentials by their nature are
    liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do
    not cater for this. Whereas with floating-point -- well, it?s there in
    the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe even a
    128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++. The last thing I want to do is introduce more new features in the code.

    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 Aug 14 01:14:11 2026
    On 8/13/2026 9:58 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 8:07 AM, Lynn McGuire wrote:
    On 8/13/2026 4:19 AM, Johann 'Myrkraverk' Oskarsson wrote:
    On 11/08/2026 4:01 PM, Lynn McGuire wrote:
    Why is there not a ipow version of pow?

    ipow would return an int instead of a double.ÿ Or a long long int.

    Thanks,
    Lynn


    Dear Lynn,

    I can't speak for the ISO C committee, but my guess is the lack of a
    multi precision library in the standard.ÿ If I remember Tom St Denis'
    book correctly, implementing an ipow() with such a library is /trivial/
    for some version of trivial.ÿ I just don't remember if such a function
    is included in his.

    In any case, I don't think an ipow() is all that useful unless there is
    a multiprecision type to return the value.ÿ Do you disagree with that?

    I would rather see a standard user interface toolkit for C++ first.

    Fair enough.ÿ I come at this discussion from comp.lang.c, and as such,
    don't care what the C++ standards committee does.


    https://wxwidgets.org/ is close but I have yet to try it out.

    I just treat IUP as an /industry standard/ interface toolkit for C.

    ÿ https://iup.sourceforge.net/

    And I believe that would require a different standards committee than
    -- what was it? WG14 -- to include in the ISO standards collection, as
    it's still targetting C89 if I'm not mistaken, and doesn't keep up with
    WG14 at all.

    Perhaps just best to standardize it with A.N.S.I. in the United States,
    if at all?ÿ I admit ignorance on how much paperwork that is, and I'd certainly include PUC Rio in such discussions, somehow.ÿ Even if they're
    also not in the United States.


    Best wishes, and happy interfacing with IUP!

    Here is a couple of screenshots of our Windows User Interface using MFC
    and a dialog toolkit that I ported from our Smalltalk app a few decades ago:
    https://www.winsim.com/screenshots.html

    As you can see, we use a diagrammatic user interface very similar to
    Visio. Ours was written back in the Windows 1.0 days in the 1980s and significantly enhanced over the years. I would like to get Mac and
    Linux versions. And port to 64 bit as some of our simulation flowsheets
    are approaching 1 GB where we run out of memory at that point.

    I looked at IUP. Looks interesting.

    Thanks,
    Lynn


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Fri Aug 14 14:47:19 2026
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s
    all down to dynamic range. Logs and exponentials by their nature are
    liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do
    not cater for this. Whereas with floating-point -- well, it?s there in >>>> the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe even
    a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to do is introduce more new features in the code.

    Lynn


    Fair enough. If you change your mind -- and for other people interested
    in the subject -- you can look at chapter seven of Tom's book. Of
    course, you won't need to read the details of the implementation just to
    use the library, which is available somewhere on GitHub.


    Have a nice day!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 14 08:57:12 2026
    On 14/08/2026 01:59, Lynn McGuire wrote:
    On 8/13/2026 1:38 AM, David Brown wrote:
    On 12/08/2026 23:49, Lynn McGuire wrote:
    [...]
    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve.ÿ For me, 200 points is
    the point where diminishing returns has set in.ÿ Of course, YMMV.


    Your mileage may very much vary.ÿ The best number of points depends on
    many factors, such as the type of curve (how "wiggly" it is, whether
    it has additional characteristics like monoticity that you can use,
    etc.), whether you are using linearly separated points or free points,
    how your interpolation works, what characteristics you need for the
    generated results, your required precision, etc.ÿ Characteristics of
    the target architecture can influence the best choice of points -
    bigger tables may let you use simpler calculations, but calculations
    may be cheaper than more complicated table lookup schemes.ÿ There is
    no single guideline for the number of points in such tables that can
    be useful in any general sense.

    [...]

    Mine is coming from a chemical process simulator where chemicals are
    moving between the four phases of matter that we support: vapor,
    hydrocarbon liquid, aqueous liquid, and solids, based on temperature and pressure.ÿ The tables are incredibly non-linear.


    Sure, for particularly "wiggly" curves, or paths with discontinuities,
    you need a lot more information to describe them - that means more
    points, or more complex interpolation between them. (I am using "interpolation" in a general sense here, including any kind of
    polynomial approximation - not specifically simple linear
    interpolation.) I have no doubt that you need more points than I need -
    there is no universal rule of thumb for table size that suits a range of applications.


    --- 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 Aug 14 13:54:54 2026
    On 8/14/2026 1:47 AM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s >>>>> all down to dynamic range. Logs and exponentials by their nature are >>>>> liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do >>>>> not cater for this. Whereas with floating-point -- well, it?s there in >>>>> the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe even
    a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to do
    is introduce more new features in the code.

    Lynn


    Fair enough.ÿ If you change your mind -- and for other people interested
    in the subject -- you can look at chapter seven of Tom's book.ÿ Of
    course, you won't need to read the details of the implementation just to
    use the library, which is available somewhere on GitHub.


    Have a nice day!

    BTW, in Smalltalk you can return any type of object from a method. But
    if the caller got a weird object back, it was a place of confusion and
    often a crash as the expected object type was not the actual object
    type. So, all objects had to have a common set of methods (read, write, print, add, etc) to keep weird crashes from happening. I ended up
    putting all methods at an object and the base object too. Our base
    object had hundreds of methods to handle weird cases.

    I way prefer strongly typed languages now. Stops a lot of crazy at
    runtime, also known as crashes.

    Lynn


    --- 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 Aug 14 12:03:07 2026
    On 8/13/2026 11:47 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s >>>>> all down to dynamic range. Logs and exponentials by their nature are >>>>> liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do >>>>> not cater for this. Whereas with floating-point -- well, it?s there in >>>>> the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe even
    a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to do
    is introduce more new features in the code.

    Lynn


    Fair enough.ÿ If you change your mind -- and for other people interested
    in the subject -- you can look at chapter seven of Tom's book.ÿ Of
    course, you won't need to read the details of the implementation just to
    use the library, which is available somewhere on GitHub.


    Have a nice day!

    The have a nice day, and the -- are tell tale signs of an AI writing
    your responses?

    --- 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 Aug 14 12:08:10 2026
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals are
    moving between the four phases of matter that we support: vapor,
    hydrocarbon liquid, aqueous liquid, and solids, based on temperature
    and pressure.ÿ The tables are incredibly non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do some of
    them look fractal?

    --- 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 Aug 14 12:46:22 2026
    On 8/13/2026 11:57 PM, David Brown wrote:
    On 14/08/2026 01:59, Lynn McGuire wrote:
    On 8/13/2026 1:38 AM, David Brown wrote:
    On 12/08/2026 23:49, Lynn McGuire wrote:
    [...]
    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve.ÿ For me, 200 points
    is the point where diminishing returns has set in.ÿ Of course, YMMV.


    Your mileage may very much vary.ÿ The best number of points depends
    on many factors, such as the type of curve (how "wiggly" it is,
    whether it has additional characteristics like monoticity that you
    can use, etc.), whether you are using linearly separated points or
    free points, how your interpolation works, what characteristics you
    need for the generated results, your required precision, etc.
    Characteristics of the target architecture can influence the best
    choice of points - bigger tables may let you use simpler
    calculations, but calculations may be cheaper than more complicated
    table lookup schemes.ÿ There is no single guideline for the number of
    points in such tables that can be useful in any general sense.

    [...]

    Mine is coming from a chemical process simulator where chemicals are
    moving between the four phases of matter that we support: vapor,
    hydrocarbon liquid, aqueous liquid, and solids, based on temperature
    and pressure.ÿ The tables are incredibly non-linear.


    Sure, for particularly "wiggly" curves, or paths with discontinuities,
    you need a lot more information to describe them - that means more
    points, or more complex interpolation between them.ÿ (I am using "interpolation" in a general sense here, including any kind of
    polynomial approximation - not specifically simple linear
    interpolation.)ÿ I have no doubt that you need more points than I need - there is no universal rule of thumb for table size that suits a range of applications.


    Here is a fairly interesting interpolation... Fwiw, here is my driver
    code. I learned about this algo on a BASIC group. too funny! I ported it
    over to my system. It generates some frames for an animation:

    #pragma once


    #include "ct_multi_thread_field_final.hpp"
    #include "ct_cairo.hpp"
    #include "ct_complex.hpp"
    #include "ct_geometry.hpp"
    #include "ct_glm.hpp"

    #include <iostream>
    #include <vector>
    #include <cstdlib>
    #include <cstdio>
    #include <string>


    namespace ct {

    namespace swimmer {


    struct settings
    {
    float radius = 1;
    float t = 0;
    int n_points = 3000;
    float lw = 1;
    float sin_mul0 = 450;
    float sin_mul1 = 930;
    };

    void
    draw(
    ct::plot::cairo::plot_2d& plot,
    settings const& cfg
    ) {
    glm::vec2 prev(0.0f, 0.0f);

    for (int i = 0; i < cfg.n_points; ++i)
    {
    float a = (float)i / (cfg.n_points - 1);

    float at = 2 * a * CT_PI - 8 * cfg.t;
    float b = glm::sin(cfg.sin_mul0 * a) * (0.7f + glm::sin(cfg.sin_mul1 * a));

    float e = 2 * a * glm::exp(-a * 8);
    float l = 1.5f * (0.7f - a) * (1 - b * b / 8) + cfg.t;
    float w = e * b - glm::sin(at) / 12 + 0.75f;

    glm::vec2 p(w * glm::cos(l), w * glm::sin(l));
    p *= cfg.radius;

    if (i > 0)
    {
    int col = (int)(128 + 127 * glm::cos(4 * b - a * 6));
    unsigned char red = (unsigned char)glm::clamp(col,
    0, 255);
    unsigned char blue = (unsigned char)glm::clamp(255
    - col, 0, 255);

    ct::plot::cairo::pixel color = CT_RGB(red, 255, blue);
    plot.line(prev, p, color, cfg.lw);
    }

    prev = p;
    }
    }


    void
    draw_pinwheel(
    ct::plot::cairo::plot_2d& plot,
    float t,
    unsigned long n = 10
    ) {
    float normal_base = 1.f / (n - 1);

    for (unsigned long i = 0; i < n; ++i)
    {
    float normal = normal_base * i;

    float r = normal;
    float local_t = normal * n * 10 + t; // outer t
    offsets the whole formation

    draw(plot, { .radius = r, .t = local_t, .lw = 2 });
    }
    }


    void
    manifest_anime(
    ct::plot::cairo::plot_2d& scene,
    unsigned long fps,
    unsigned long duration
    ) {
    unsigned long frames = fps * duration;

    float normal_base = 1.f / frames;

    for (unsigned long i = 0; i < frames; ++i)
    {
    float normal = normal_base * i;
    float t = CT_PI2 * normal;

    scene.clear(CT_RGBF(0, 0, 0));

    draw_pinwheel(scene, t, 16);

    {
    std::string filename =
    "./ct_swimmer/frames/ct_frame_" + std::to_string(i) + ".png";

    std::cout << "filename = " << filename << "\n";
    std::cout << "normal = " << normal << "\n";
    std::cout << "t = " << t << std::endl;

    scene.save(filename.c_str());
    }
    }
    }

    void
    manifest(
    ct::plot::cairo::plot_2d& scene
    ) {
    std::cout << "ct::swimmer()\n";
    std::cout << "__________________________________\n" <<
    std::endl;

    {
    manifest_anime(scene, 24, 5);
    }

    {
    // draw_pinwheel(scene, 0.0f);
    // draw_pinwheel(scene, 0.5f);
    // draw_pinwheel(scene, 0.75f);
    // draw_pinwheel(scene, 1.f);
    // draw_pinwheel(scene, 2.f);
    //draw_pinwheel(scene, 3.f);


    }
    }
    }

    } // ct::swimmer




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Sat Aug 15 03:51:07 2026
    On 15/08/2026 3:03 AM, Chris M. Thomasson wrote:
    On 8/13/2026 11:47 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s >>>>>> all down to dynamic range. Logs and exponentials by their nature are >>>>>> liable to cover a huge range of magnitudes in either the argument
    (logarithm) or result (exponential). Integer formats in common use do >>>>>> not cater for this. Whereas with floating-point -- well, it?s
    there in
    the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe
    even a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the
    one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to do
    is introduce more new features in the code.

    Lynn


    Fair enough.ÿ If you change your mind -- and for other people interested
    in the subject -- you can look at chapter seven of Tom's book.ÿ Of
    course, you won't need to read the details of the implementation just to
    use the library, which is available somewhere on GitHub.


    Have a nice day!

    The have a nice day, and the -- are tell tale signs of an AI writing
    your responses?

    Is the expression /tell tale/ a sign of you insisting I use A.I. when
    you know I don't? Do you get off of writing tall tales? Do you post
    in alt.sex.erotica.moderated? Are you the moderator?

    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 14 12:52:31 2026
    On 8/14/2026 12:51 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 15/08/2026 3:03 AM, Chris M. Thomasson wrote:
    On 8/13/2026 11:47 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: it?s >>>>>>> all down to dynamic range. Logs and exponentials by their nature are >>>>>>> liable to cover a huge range of magnitudes in either the argument >>>>>>> (logarithm) or result (exponential). Integer formats in common
    use do
    not cater for this. Whereas with floating-point -- well, it?s
    there in
    the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe
    even a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the >>>>> one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to do
    is introduce more new features in the code.

    Lynn


    Fair enough.ÿ If you change your mind -- and for other people interested >>> in the subject -- you can look at chapter seven of Tom's book.ÿ Of
    course, you won't need to read the details of the implementation just to >>> use the library, which is available somewhere on GitHub.


    Have a nice day!

    The have a nice day, and the -- are tell tale signs of an AI writing
    your responses?

    Is the expression /tell tale/ a sign of you insisting I use A.I. when
    you know I don't?ÿ Do you get off of writing tall tales?ÿ Do you post
    in alt.sex.erotica.moderated?ÿ Are you the moderator?


    Are you using AI to help write your responses? There are some flags.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Sat Aug 15 04:01:14 2026
    On 15/08/2026 3:52 AM, Chris M. Thomasson wrote:
    On 8/14/2026 12:51 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 15/08/2026 3:03 AM, Chris M. Thomasson wrote:
    On 8/13/2026 11:47 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 14/08/2026 2:00 PM, Lynn McGuire wrote:
    On 8/13/2026 10:22 PM, Johann 'Myrkraverk' Oskarsson wrote:
    On 12/08/2026 2:37 PM, Lynn McGuire wrote:
    On 8/11/2026 11:26 PM, Lawrence D?Oliveiro wrote:
    On Tue, 11 Aug 2026 03:01:07 -0500, Lynn McGuire wrote:

    Why is there not a ipow version of pow?

    Perhaps for the same reason there aren?t integer log functions: >>>>>>>> it?s
    all down to dynamic range. Logs and exponentials by their nature >>>>>>>> are
    liable to cover a huge range of magnitudes in either the argument >>>>>>>> (logarithm) or result (exponential). Integer formats in common >>>>>>>> use do
    not cater for this. Whereas with floating-point -- well, it?s >>>>>>>> there in
    the name, isn?t it?

    This is why you calculate and return a long long int.ÿ Or maybe >>>>>>> even a 128 bit int.

    Lynn


    Is there a reason you don't use a multiprecision library, such as the >>>>>> one by the late Tom St Denis, in your code base?

    I am converting from Fortran 77 to C++.ÿ The last thing I want to
    do is introduce more new features in the code.

    Lynn


    Fair enough.ÿ If you change your mind -- and for other people
    interested
    in the subject -- you can look at chapter seven of Tom's book.ÿ Of
    course, you won't need to read the details of the implementation
    just to
    use the library, which is available somewhere on GitHub.


    Have a nice day!

    The have a nice day, and the -- are tell tale signs of an AI writing
    your responses?

    Is the expression /tell tale/ a sign of you insisting I use A.I. when
    you know I don't?ÿ Do you get off of writing tall tales?ÿ Do you post
    in alt.sex.erotica.moderated?ÿ Are you the moderator?


    Are you using AI to help write your responses? There are some flags.

    You're completely free to capture the flag on your own. You'll just
    have to write the game in C, because I'm coming at this from comp.lang.
    c. And not comp.lang.c++.

    I still type my replies by hand, but you're unable to do so, so you must dictate to Siri, which sends the request to Copilot, which hopefully
    uses the most expensive Usenet service available for your posts. I
    mean, why stop at paying both the fruit vendor for Siri, and Microsoft
    for Copilot, and not get the world's best and greatest Usenet provider?


    Happy posting on Usenet with Siri and Copilot!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 14 13:27:14 2026
    On 8/14/2026 1:01 PM, Johann 'Myrkraverk' Oskarsson wrote:
    [...]
    You're completely free to capture the flag on your own.ÿ You'll just
    have to write the game in C, because I'm coming at this from comp.lang.
    c.ÿ And not comp.lang.c++.

    I still type my replies by hand, but you're unable to do so, so you must dictate to Siri, which sends the request to Copilot, which hopefully
    uses the most expensive Usenet service available for your posts.ÿ I
    mean, why stop at paying both the fruit vendor for Siri, and Microsoft
    for Copilot, and not get the world's best and greatest Usenet provider?


    Happy posting on Usenet with Siri and Copilot!

    Huh. So, you are an "ass" all by yourself?

    --- 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 Aug 14 13:29:13 2026
    On 8/14/2026 1:27 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:01 PM, Johann 'Myrkraverk' Oskarsson wrote:
    [...]
    You're completely free to capture the flag on your own.ÿ You'll just
    have to write the game in C, because I'm coming at this from comp.lang.
    c.ÿ And not comp.lang.c++.

    I still type my replies by hand, but you're unable to do so, so you must
    dictate to Siri, which sends the request to Copilot, which hopefully
    uses the most expensive Usenet service available for your posts.ÿ I
    mean, why stop at paying both the fruit vendor for Siri, and Microsoft
    for Copilot, and not get the world's best and greatest Usenet provider?


    Happy posting on Usenet with Siri and Copilot!

    Huh. So, you are an "ass" all by yourself?

    The -- and the final "have a happy ..." aspects reek of AI all over...

    --- 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 Aug 14 15:48:55 2026
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals are
    moving between the four phases of matter that we support: vapor,
    hydrocarbon liquid, aqueous liquid, and solids, based on temperature
    and pressure.ÿ The tables are incredibly non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do some of them look fractal?

    In short, no. We have a diagrammatic user interface that allows our
    users to build a diagram of a chemical process flow diagram such as a refinery, a natural gas plan, a pipeline with compressor stations, or a chemical plant.
    https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of that
    diagram and solves it thermodynamically. If, it can be solved as not
    all chemical processes can be solved due to constraints or violation of
    the laws of thermodynamics.

    Thanks,
    Lynn


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Sat Aug 15 04:49:05 2026
    On 15/08/2026 4:29 AM, Chris M. Thomasson wrote:
    On 8/14/2026 1:27 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:01 PM, Johann 'Myrkraverk' Oskarsson wrote:
    [...]
    You're completely free to capture the flag on your own.ÿ You'll just
    have to write the game in C, because I'm coming at this from comp.lang.
    c.ÿ And not comp.lang.c++.

    I still type my replies by hand, but you're unable to do so, so you must >>> dictate to Siri, which sends the request to Copilot, which hopefully
    uses the most expensive Usenet service available for your posts.ÿ I
    mean, why stop at paying both the fruit vendor for Siri, and Microsoft
    for Copilot, and not get the world's best and greatest Usenet provider?


    Happy posting on Usenet with Siri and Copilot!

    Huh. So, you are an "ass" all by yourself?

    The -- and the final "have a happy ..." aspects reek of AI all over...

    Ah, yes. You're still having problems with the distinction between
    fantasy and reality. I believe I've told you this before, and you
    didn't listen then, so I can only surmise you cannot handle the truth.

    I /write well/. I can write micro-fiction for my own amusement all day
    long. And since I have no interest in amusing you, you fucking asshole,
    I guess this is the last I'll ever say on this subject. I don't need to
    use L.L.M. The L.L.Ms. were trained on the best of us. I'm one.


    Deal with it, you fucking cuck!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 14 13:51:43 2026
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals
    are moving between the four phases of matter that we support:
    vapor, hydrocarbon liquid, aqueous liquid, and solids, based on
    temperature and pressure.ÿ The tables are incredibly non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do some
    of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows our
    users to build a diagram of a chemical process flow diagram such as a refinery, a natural gas plan, a pipeline with compressor stations, or a chemical plant.
    ÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of that diagram and solves it thermodynamically.ÿ If, it can be solved as not
    all chemical processes can be solved due to constraints or violation of
    the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay. But
    you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples here:

    https://youtu.be/YS-tyDJVy4M

    --- 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 Aug 14 16:40:26 2026
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals
    are moving between the four phases of matter that we support:
    vapor, hydrocarbon liquid, aqueous liquid, and solids, based on
    temperature and pressure.ÿ The tables are incredibly non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do some
    of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows our
    users to build a diagram of a chemical process flow diagram such as a
    refinery, a natural gas plan, a pipeline with compressor stations, or
    a chemical plant.
    ÿÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of that
    diagram and solves it thermodynamically.ÿ If, it can be solved as not
    all chemical processes can be solved due to constraints or violation
    of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay. But
    you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram
    (PSD). If the users run a dynamic (time sensitive) version of the
    simulation, the user can roll through their displayed results on the
    various sheets of the PSD using their time breaks.

    Lynn


    --- 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 Aug 14 19:24:28 2026
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals >>>>>>> are moving between the four phases of matter that we support:
    vapor, hydrocarbon liquid, aqueous liquid, and solids, based on >>>>>>> temperature and pressure.ÿ The tables are incredibly non-linear. >>>>>>>
    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do
    some of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows our
    users to build a diagram of a chemical process flow diagram such as a
    refinery, a natural gas plan, a pipeline with compressor stations, or
    a chemical plant.
    ÿÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of that
    diagram and solves it thermodynamically.ÿ If, it can be solved as not
    all chemical processes can be solved due to constraints or violation
    of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay.
    But you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram
    (PSD).

    Can you give me a link to some screenshots so I can get on the same
    page? Thanks. Are you almost done with your Fortran port?


    If the users run a dynamic (time sensitive) version of the
    simulation, the user can roll through their displayed results on the
    various sheets of the PSD using their time breaks.

    Cool. Fwiw, check this shit out:

    https://youtu.be/poXeq5V0dso

    A simulation for the field of one of my circle intersection fractals.


    --- 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 Aug 14 20:32:52 2026
    On 8/14/2026 1:49 PM, Johann 'Myrkraverk' Oskarsson wrote:
    [...]

    Deal with it, you fucking cuck!

    Ahhh. Again. I am right.

    --- 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 Aug 14 22:51:02 2026
    On 8/14/2026 9:24 PM, Chris M. Thomasson wrote:
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where chemicals >>>>>>>> are moving between the four phases of matter that we support: >>>>>>>> vapor, hydrocarbon liquid, aqueous liquid, and solids, based on >>>>>>>> temperature and pressure.ÿ The tables are incredibly non-linear. >>>>>>>>
    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do
    some of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows our
    users to build a diagram of a chemical process flow diagram such as
    a refinery, a natural gas plan, a pipeline with compressor stations,
    or a chemical plant.
    ÿÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of
    that diagram and solves it thermodynamically.ÿ If, it can be solved
    as not all chemical processes can be solved due to constraints or
    violation of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay.
    But you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples
    here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram (PSD).

    Can you give me a link to some screenshots so I can get on the same
    page? Thanks. Are you almost done with your Fortran port?
    ...

    https://www.winsim.com/screenshots.html

    I am about 1/3rd of the way done with my 800,000 lines of F77 code to
    C++ code. My custom version of F2C is doing about 60 to 70% of the
    work. I am equating the task as equivalent to translating about ten
    long engineering books from German to French. Lots of idioms and basic incompatibilities that have to be ironed out.

    I was shooting for the end of 2026 but that ship has sailed. Maybe
    middle of 2027. Then I have to port to x64 but the port should be easy
    (he says with the ship sitting in ten feet of mud in the harbor).

    Lynn


    --- 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 Aug 14 22:33:01 2026
    On 8/14/2026 8:51 PM, Lynn McGuire wrote:
    On 8/14/2026 9:24 PM, Chris M. Thomasson wrote:
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where
    chemicals are moving between the four phases of matter that we >>>>>>>>> support: vapor, hydrocarbon liquid, aqueous liquid, and solids, >>>>>>>>> based on temperature and pressure.ÿ The tables are incredibly >>>>>>>>> non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do
    some of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows
    our users to build a diagram of a chemical process flow diagram
    such as a refinery, a natural gas plan, a pipeline with compressor
    stations, or a chemical plant.
    ÿÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of
    that diagram and solves it thermodynamically.ÿ If, it can be solved >>>>> as not all chemical processes can be solved due to constraints or
    violation of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay.
    But you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples
    here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram
    (PSD).

    Can you give me a link to some screenshots so I can get on the same
    page? Thanks. Are you almost done with your Fortran port?
    ...

    https://www.winsim.com/screenshots.html

    I am about 1/3rd of the way done with my 800,000 lines of F77 code to C+
    + code.ÿ My custom version of F2C is doing about 60 to 70% of the work.
    I am equating the task as equivalent to translating about ten long engineering books from German to French.ÿ Lots of idioms and basic incompatibilities that have to be ironed out.

    I was shooting for the end of 2026 but that ship has sailed.ÿ Maybe
    middle of 2027.ÿ Then I have to port to x64 but the port should be easy
    (he says with the ship sitting in ten feet of mud in the harbor).

    Lynn


    Love the flow sheet. Now from there, can you create a vector field?

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Sat Aug 15 10:40:50 2026
    On 08/14/2026 08:51 PM, Lynn McGuire wrote:
    On 8/14/2026 9:24 PM, Chris M. Thomasson wrote:
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where
    chemicals are moving between the four phases of matter that we >>>>>>>>> support: vapor, hydrocarbon liquid, aqueous liquid, and solids, >>>>>>>>> based on temperature and pressure. The tables are incredibly >>>>>>>>> non-linear.

    This is my people and I:
    https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do
    some of them look fractal?

    In short, no. We have a diagrammatic user interface that allows
    our users to build a diagram of a chemical process flow diagram
    such as a refinery, a natural gas plan, a pipeline with compressor
    stations, or a chemical plant.
    https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of
    that diagram and solves it thermodynamically. If, it can be solved
    as not all chemical processes can be solved due to constraints or
    violation of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay.
    But you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples
    here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram
    (PSD).

    Can you give me a link to some screenshots so I can get on the same
    page? Thanks. Are you almost done with your Fortran port?
    ...

    https://www.winsim.com/screenshots.html

    I am about 1/3rd of the way done with my 800,000 lines of F77 code to
    C++ code. My custom version of F2C is doing about 60 to 70% of the
    work. I am equating the task as equivalent to translating about ten
    long engineering books from German to French. Lots of idioms and basic incompatibilities that have to be ironed out.

    I was shooting for the end of 2026 but that ship has sailed. Maybe
    middle of 2027. Then I have to port to x64 but the port should be easy
    (he says with the ship sitting in ten feet of mud in the harbor).

    Lynn


    Translating the idioms right makes for "naturals" alignment and storage,
    and so on. Then the numerical methods one imagines are
    involved in solving linearities for invariants and process control,
    then that's involved itself, and the relevance of the compatibility
    of the numerical methods, for their mathematical guarantees, for
    their physical estimates, about how many traincars and truckloads
    of feeder stock under what conditions and augury make diapers or
    galoshes or legos or condoms or pipe or contact lenses or lacquer
    or petrochemicals or drugs or otherwise usually enough more refined
    materials from more raw materials.

    Here it's like "measure-twice cut-once" the old "build a fence
    a mile, could you move it a foot?"

    If the great difference for FORTRAN and C is the account of
    the column-major or row-major and that of arrays and loops,
    then besides a simplest sort of transpose, or organization
    and alignment and storage, then is for the model of computation
    the entry-points and the state & scope, the modules, point being here
    it's perceived as a quite impressive and thoroughgoing sort of
    account of quite very much the value the algorithms and numerical
    methods express as models of control theory.

    The Bessemer furnace, ....

    https://en.wikipedia.org/wiki/Bessemer_process

    Then, there was mentioned "violations of the thermo second law",
    or rather, "accommodations to effects of resonance theory",
    these sorts acconts of "effects", which are basically anything
    outside otherwise the theory, or "exceptions", yes one imagines
    that those make for the accounts of state & scope the quite
    complicated, which for example "exception specification" provides
    in higher-level languages with exception specification as a critical
    component of safety in the modules of software, quite invokes the
    deliberations of "why" instead of merely "because".


    The, "term-rewriting", or a bit more holistically the
    "term-graph-rewriting", is definitely a thing in software since that "generative programming" is a term from the 1960's, and "program
    translation" is is quite usual, then for "models of computation"
    and "modules of computation".


    Long story short such an endeavor is perceived to be a store of
    great _value_, and such porting effort is quite a study of both
    the numerical methods, which as usually approximations need
    their error-bounds modeled, like Runge-Kutta for example after
    Gregory & Coates as Newton's, or about Leontief and so on,
    numerical methods and linear systems and linear solvers,
    then with regards to standard and empirical units, which are
    not necessarily the same and where regimes of effect are
    according to their own units, good luck with that, it sounds
    like something vital to the real-world economy.





    --- 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 Aug 15 11:41:09 2026
    On 8/15/2026 10:40 AM, Ross Finlayson wrote:
    [...]
    Long story short such an endeavor is perceived to be a store of
    great _value_, and such porting effort is quite a study of both
    the numerical methods, which as usually approximations need
    their error-bounds modeled, like Runge-Kutta for example after
    Gregory & Coates as Newton's, or about Leontief and so on,
    numerical methods and linear systems and linear solvers,
    then with regards to standard and empirical units, which are
    not necessarily the same and where regimes of effect are
    according to their own units, good luck with that, it sounds
    like something vital to the real-world economy.

    Long story short... I am not using RK for the intermediate vector field integration points, but its still pretty good. Example:

    https://youtu.be/Doeci7xBYh0



    --- 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 Sat Aug 15 13:00:22 2026
    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve. For me, 200 points is
    the point where diminishing returns has set in. Of course, YMMV.

    Surely that depends on which integration method is being used.

    --- 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 Sat Aug 15 23:17:16 2026
    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best when performing a numerical integration of a curve. For me, 200 points
    is the point where diminishing returns has set in. Of course,
    YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not talk
    at all about integration.


    --- 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 Sun Aug 16 07:33:42 2026
    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    long long int ipow(long long a, int n) {
    long long int res;

    res = 1;
    if (n < 0) {
    res = 0;

    } else if (n == 0) {
    res = 1;

    } else if (n == 1) {
    res = a;

    } else if ((n & 1) == 0) { // n is even
    res = ipow(a*a, n/2);

    } else { // n is odd
    res = ipow(a*a, (n-1)/2)*a;
    }

    return res;
    }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    Two: it gets wrong answers for in some cases with negative
    exponents.

    --- 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 Sun Aug 16 17:12:02 2026
    On 2026-08-16 16:33, Tim Rentsch wrote:
    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    long long int ipow(long long a, int n) {
    long long int res;

    res = 1;
    if (n < 0) {
    res = 0;

    } else if (n == 0) {
    res = 1;

    } else if (n == 1) {
    res = a;

    } else if ((n & 1) == 0) { // n is even
    res = ipow(a*a, n/2);

    } else { // n is odd
    res = ipow(a*a, (n-1)/2)*a;
    }

    return res;
    }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    (But personally I find the recursive form clearer than an iterative.)


    Two: it gets wrong answers for in some cases with negative
    exponents.

    Ah, a typical non-answer! - Given that negative exponents are (here)
    generally handled to provide a result of 0 - and assuming that is
    accepted as result, since other libraries may provide an exception
    or error here - what are these "some cases with negative exponents"
    you have in mind; if you are so deign to give an answer this time.

    Thanks.

    Janis


    --- 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 Sun Aug 16 17:51:25 2026
    On 16/08/2026 17:12, Janis Papanagnou wrote:
    On 2026-08-16 16:33, Tim Rentsch wrote:
    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    ÿ long long int ipow(long long a, int n) {
    ÿÿÿÿ long long int res;

    ÿÿÿÿ res = 1;
    ÿÿÿÿ if (n < 0) {
    ÿÿÿÿÿÿÿÿ res = 0;

    ÿÿÿÿ } else if (n == 0) {
    ÿÿÿÿÿÿÿÿ res = 1;

    ÿÿÿÿ } else if (n == 1) {
    ÿÿÿÿÿÿÿÿ res = a;

    ÿÿÿÿ } else if ((n & 1) == 0) {ÿÿÿÿÿÿÿ // n is even
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, n/2);

    ÿÿÿÿ } else {ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ // n is odd
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, (n-1)/2)*a;
    ÿÿÿÿ }

    ÿÿÿÿ return res;
    ÿ }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    (But personally I find the recursive form clearer than an iterative.)


    Two: it gets wrong answers for in some cases with negative
    exponents.

    Ah, a typical non-answer! - Given that negative exponents are (here) generally handled to provide a result of 0 - and assuming that is
    accepted as result, since other libraries may provide an exception
    or error here - what are these "some cases with negative exponents"
    you have in mind; if you are so deign to give an answer this time.


    1 ** n will be 1, even for negative n. And -1 ** n will be 1 for even negative n, -1 for odd negative n. (Tim does not seem to give useful
    answers much these days - he does drive-bys every few months and leaves comments that are not much better than "I'm smarter than you". He used
    to take more active part in threads, so you'd at least get a more
    helpful response within a few days, but unfortunately that is now uncommon.)

    It might not be unreasonable to have fast special cases for n = 1 or -1
    at the start.

    gcc and clang have no problem generating iterative code from this
    function, but MSVC did not manage it (or possibly I don't know the right
    MSVC flags - "/O2" was not sufficient in a quick godbolt test).

    I don't know how Bart's own compiler copes with such recursive functions
    - I am curious if it can generate an iterative loop here.


    --- 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 Sun Aug 16 18:35:24 2026
    On 2026-08-16 17:51, David Brown wrote:
    On 16/08/2026 17:12, Janis Papanagnou wrote:
    On 2026-08-16 16:33, Tim Rentsch wrote:
    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    ÿ long long int ipow(long long a, int n) {
    ÿÿÿÿ long long int res;

    ÿÿÿÿ res = 1;
    ÿÿÿÿ if (n < 0) {
    ÿÿÿÿÿÿÿÿ res = 0;

    ÿÿÿÿ } else if (n == 0) {
    ÿÿÿÿÿÿÿÿ res = 1;

    ÿÿÿÿ } else if (n == 1) {
    ÿÿÿÿÿÿÿÿ res = a;

    ÿÿÿÿ } else if ((n & 1) == 0) {ÿÿÿÿÿÿÿ // n is even
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, n/2);

    ÿÿÿÿ } else {ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ // n is odd
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, (n-1)/2)*a;
    ÿÿÿÿ }

    ÿÿÿÿ return res;
    ÿ }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    (But personally I find the recursive form clearer than an iterative.)


    Two: it gets wrong answers for in some cases with negative
    exponents.

    Ah, a typical non-answer! - Given that negative exponents are (here)
    generally handled to provide a result of 0 - and assuming that is
    accepted as result, since other libraries may provide an exception
    or error here - what are these "some cases with negative exponents"
    you have in mind; if you are so deign to give an answer this time.


    1 ** n will be 1, even for negative n.

    For the integer-exponentiation case as topic of the thread - where
    negative exponents make little sense - and specifically for bart's
    presented code "negative n" is ruled out, or rather it leads always
    to 0.

    I'd assume you (and Tim) just missed that? (Or what did I miss?)

    And -1 ** n will be 1 for even negative n,

    I'd say it would be at best undefined. In the posted code it would
    be 0, which is not unsound if we'd read (now coming from the general
    case) x**-y as 1/(x**y), which goes (in the 'real' domain) towards 0.

    As said, other languages or libraries just bail out for the negative
    exponent case ipow: int x int -> int (or rather int x nat -> nat ).

    -1 for odd negative n.ÿ (Tim does not seem to give useful
    answers much these days - he does drive-bys every few months and leaves comments that are not much better than "I'm smarter than you".ÿ He used
    to take more active part in threads, so you'd at least get a more
    helpful response within a few days, but unfortunately that is now
    uncommon.)

    Yes, that's obvious. (But it's cumbersome and not worthwhile to talk
    about - crude or else - personalities.)

    [...]

    I don't know how Bart's own compiler copes with such recursive functions
    - I am curious if it can generate an iterative loop here.

    Well, Bart's tools are of little interest - to me at least. But his
    posted algorithm is sound, I'd say. And an iterative replacement not
    hard to derive. Maybe something like (replacing long long for brevity)

    long ipow (long a, int n)
    {
    if (n < 0) return 0;

    long res = 1;
    long base = a; // note: we could also operate on 'a'

    while (n > 0) {
    if (n & 1)
    res *= base;

    base *= base;
    n /= 2;
    }

    return res;
    }

    But as said, for _clarity_ of code I prefer the functional form.

    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 Sun Aug 16 18:41:20 2026
    On 2026-08-16 18:35, Janis Papanagnou wrote:

    As said, other languages or libraries just bail out for the negative
    exponent caseÿ ipow: int x int -> intÿ (or ratherÿ int x nat -> nat ).

    Oops, typo... ipow: int x int -> int (or rather int x nat -> int ).

    Janis


    --- 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 Sun Aug 16 21:30:53 2026
    On 16/08/2026 18:35, Janis Papanagnou wrote:
    On 2026-08-16 17:51, David Brown wrote:
    On 16/08/2026 17:12, Janis Papanagnou wrote:
    On 2026-08-16 16:33, Tim Rentsch wrote:
    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    ÿ long long int ipow(long long a, int n) {
    ÿÿÿÿ long long int res;

    ÿÿÿÿ res = 1;
    ÿÿÿÿ if (n < 0) {
    ÿÿÿÿÿÿÿÿ res = 0;

    ÿÿÿÿ } else if (n == 0) {
    ÿÿÿÿÿÿÿÿ res = 1;

    ÿÿÿÿ } else if (n == 1) {
    ÿÿÿÿÿÿÿÿ res = a;

    ÿÿÿÿ } else if ((n & 1) == 0) {ÿÿÿÿÿÿÿ // n is even
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, n/2);

    ÿÿÿÿ } else {ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ // n is odd
    ÿÿÿÿÿÿÿÿ res = ipow(a*a, (n-1)/2)*a;
    ÿÿÿÿ }

    ÿÿÿÿ return res;
    ÿ }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    (But personally I find the recursive form clearer than an iterative.)


    Two: it gets wrong answers for in some cases with negative
    exponents.

    Ah, a typical non-answer! - Given that negative exponents are (here)
    generally handled to provide a result of 0 - and assuming that is
    accepted as result, since other libraries may provide an exception
    or error here - what are these "some cases with negative exponents"
    you have in mind; if you are so deign to give an answer this time.


    1 ** n will be 1, even for negative n.

    For the integer-exponentiation case as topic of the thread - where
    negative exponents make little sense - and specifically for bart's
    presented code "negative n" is ruled out, or rather it leads always
    to 0.

    I'd assume you (and Tim) just missed that? (Or what did I miss?)


    I can't speak for Tim, though I would assume he is entirely aware that
    using negative n usually makes little sense for an "ipow" function - and
    I suspect that since the function takes a signed int for "n" and does
    not specify that it is non-negative, he felt the return value should be correct for negative "n" even if it is never used.

    For my own part, I am entirely aware that negative "n" makes little
    sense in practice. In the example code I gave for "ipow" in a different thread, I specifically used an unsigned type for "n".


    And -1 ** n will be 1 for even negative n,

    I'd say it would be at best undefined.

    Why? (-1) ** n is well-defined mathematically for all integer "n". It
    turns up regularly in sum notation when you want to distinguish between
    odd and even terms. "a ** -n" is just "1 / (a ** n)", so the results
    here have a clear mathematical meaning.

    But I can agree that it would rarely be useful to have a negative "n"
    for an integer power function. And if you want to specify an "ipow"
    function that is for non-negative "n" only, fair enough.

    (The really problematic cases are of course "ipow(0, n)" when n <= 0.
    These are best left as UB in the specifications, but an implementation
    might find it easiest just to return 0. When there is no right answer,
    any answer is reasonable.)

    In the posted code it would
    be 0, which is not unsound if we'd read (now coming from the general
    case) x**-y as 1/(x**y), which goes (in the 'real' domain) towards 0.


    Yes, rounding "a ** n" to 0 for negative "n" is perfectly reasonable, in
    all cases except "a = 1" and "a = -1".

    As said, other languages or libraries just bail out for the negative
    exponent caseÿ ipow: int x int -> intÿ (or ratherÿ int x nat -> nat ).


    They can choose to do that. That's fine. But it should either be part
    of the function declaration (such as using an unsigned type for "n"), or
    given in the documentation.

    [...]

    I don't know how Bart's own compiler copes with such recursive
    functions - I am curious if it can generate an iterative loop here.

    Well, Bart's tools are of little interest - to me at least.

    I have no use for his tools either, but I am interested in how well they
    work with code he writes himself in this style.

    But his
    posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a fix
    for those cases, I agree that his algorithm is fine.

    And an iterative replacement not
    hard to derive. Maybe something like (replacing long long for brevity)

    long ipow (long a, int n)
    {
    ÿÿÿ if (n < 0) return 0;

    ÿÿÿ long res = 1;
    ÿÿÿ long base = a;ÿ // note: we could also operate on 'a'

    ÿÿÿ while (n > 0) {
    ÿÿÿÿÿÿÿ if (n & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ res *= base;

    ÿÿÿÿÿÿÿ base *= base;
    ÿÿÿÿÿÿÿ n /= 2;
    ÿÿÿ }

    ÿÿÿ return res;
    }

    But as said, for _clarity_ of code I prefer the functional form.


    Me too.


    --- 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 Sun Aug 16 14:58:10 2026
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    [...]

    Fwiw, check this out, another one of my field renders:

    https://youtu.be/ygmp_XvdaqQ

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bart@3:633/10 to All on Sun Aug 16 23:41:27 2026
    On 16/08/2026 20:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:

    Well, Bart's tools are of little interest - to me at least.

    I have no use for his tools either, but I am interested in how well they work with code he writes himself in this style.

    They do nothing clever. With the version below, one test I did had these results (with the ipow function in a different file from the test code):

    gcc -O3 0.56 s
    clang -O3 0.78 s
    bcc 1.12 s
    lccwin32 1.19 s
    DMC 1.4 s (32-bit code)
    tcc 1.43 s



    But his
    posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a fix
    for those cases, I agree that his algorithm is fine.


    It's not mine, I just found it somewhere.


    -----------------------------------

    long long int ipow(long long a, unsigned int n) {
    if (n == 0) {
    return 1;

    } else if (n == 1) {
    return a;

    } else if ((n & 1) == 0) { // n is even
    return ipow(a*a, n/2);

    } else { // n is odd
    return ipow(a*a, (n-1)/2)*a;
    }
    }



    --- 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 Aug 16 22:49:05 2026
    On Fri, 14 Aug 2026 13:54:54 -0500, Lynn McGuire wrote:

    BTW, in Smalltalk you can return any type of object from a method.
    But if the caller got a weird object back, it was a place of
    confusion and often a crash as the expected object type was not the
    actual object type.

    I way prefer strongly typed languages now.

    Smalltalk IS ?strongly typed?. I think you mean ?statically typed?, as
    opposed to ?dynamically typed?.

    So, all objects had to have a common set of methods (read, write,
    print, add, etc) to keep weird crashes from happening. I ended up
    putting all methods at an object and the base object too. Our base
    object had hundreds of methods to handle weird cases.

    Shouldn?t you have cleaned up the code to deal properly with the
    different object types?

    This is why newer dynamic languages, like Python, are introducing type annotations. These are handled by a separate processor (… la ?lint?
    for C code) which tries to flag up inconsistencies between expected
    and actual types, as indicated by a static analysis of the
    annotations. This would let you fix up those inconsistencies even
    before the code gets a chance to run.

    Of course such a scheme is not perfect, and can never be, without
    giving up dynamic typing altogether. And then you?d probably end up
    with Java or something.

    --- 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 Mon Aug 17 03:32:07 2026
    On 2026-08-16 21:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:
    [...]

    But his posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a fix
    for those cases, I agree that his algorithm is fine.

    Actually, programming lots of Algol68 lately, I used a few patterns
    from that language also in my iterative code. (I had mentioned the
    unnecessary use of the "base" variable, and the 'int' parameter was
    also a remains.) In "C" (and forgetting Algol 68 for a moment) I'd
    probably have written it more "C-ish"; i.e. using an 'unsigned int'
    for the parameter 'n' to more clearly define its range as positive,
    operating directly on 'a', and condensing the 'while' loop by 'for'.

    long int ipow (long int a, unsigned int n)
    {
    long int res = 1;
    for ( ; n > 0; n /= 2) {
    if (n & 1)
    res *= a;
    a *= a;
    }
    return res;
    }

    The "n < 0" case can then also be omitted completely and adds to its
    brevity.

    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.

    Janis


    --- 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 Aug 17 06:37:10 2026
    On Thu, 13 Aug 2026 18:10:12 +0200, Bonita Montero wrote:

    It makes code less readable for nearly no gain.

    Both C and C++ programmers seem to have this philosophy of ?if in
    doubt, add more parentheses?.

    --- 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 Aug 17 06:40:56 2026
    On Thu, 13 Aug 2026 19:07:02 -0500, Lynn McGuire wrote:

    I would rather see a standard user interface toolkit for C++ first.

    With only one exception I?m aware of, there is no standard UI toolkit
    for *any* cross-platform language, for obvious reasons.

    Though interestingly, there has been a proposal knocking around among
    the C++ standardization committee for some years for a standard 2D
    graphics API. Like the one that has been incorporated in JavaScript,
    this one is also based on Cairo <https://www.cairographics.org/>, but
    unlike that, it seems to be even less complete, omitting even text functionality.

    --- 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 Aug 17 08:56:37 2026
    On 17/08/2026 00:41, bart wrote:
    On 16/08/2026 20:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:

    Well, Bart's tools are of little interest - to me at least.

    I have no use for his tools either, but I am interested in how well
    they work with code he writes himself in this style.

    They do nothing clever. With the version below, one test I did had these results (with the ipow function in a different file from the test code):

    OK. I was merely curious if you were able to do tail recursion so that
    your code here was more efficient. It's not going to make a big
    difference in practice - since real-world code will use small values of
    "n", the recursion depth is going to be very small too.


    ÿgcc -O3ÿÿÿ 0.56 s
    ÿclang -O3ÿ 0.78 s
    ÿbccÿÿÿÿÿÿÿ 1.12 s
    ÿlccwin32ÿÿ 1.19 s
    ÿDMCÿÿÿÿÿÿÿ 1.4ÿ s (32-bit code)
    ÿtccÿÿÿÿÿÿÿ 1.43 s



    But his
    posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a
    fix for those cases, I agree that his algorithm is fine.


    It's not mine, I just found it somewhere.

    Fair enough.


    --- 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 Aug 17 08:59:31 2026
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    On 2026-08-16 21:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:
    [...]

    But his posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a
    fix for those cases, I agree that his algorithm is fine.

    Actually, programming lots of Algol68 lately, I used a few patterns
    from that language also in my iterative code. (I had mentioned the unnecessary use of the "base" variable, and the 'int' parameter was
    also a remains.) In "C" (and forgetting Algol 68 for a moment) I'd
    probably have written it more "C-ish"; i.e. using an 'unsigned int'
    for the parameter 'n' to more clearly define its range as positive,
    operating directly on 'a', and condensing the 'while' loop by 'for'.

    long int ipow (long int a, unsigned int n)
    {
    ÿÿÿ long int res = 1;
    ÿÿÿ for ( ; n > 0; n /= 2) {
    ÿÿÿÿÿÿÿ if (n & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ res *= a;
    ÿÿÿÿÿÿÿ a *= a;
    ÿÿÿ }
    ÿÿÿ return res;
    }

    The "n < 0" case can then also be omitted completely and adds to its
    brevity.

    That was my thought, yes.


    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.


    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.


    --- 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 Mon Aug 17 11:08:12 2026
    On 2026-08-17 08:59, David Brown wrote:
    On 17/08/2026 03:32, Janis Papanagnou wrote:

    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.

    Some people see that as an advantage - being able to write "unsigned very_big = -1;".ÿ I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    Actually I'm ambivalent on that one. I've used -1 occasionally when
    I'm mentally operating in "C-mode"; each language has its ideograms
    and specific code and design patterns. But in other languages I do
    use things like 'min int' for that - where it's peculiar that I don't
    do that in "C" since it's (meanwhile) also available; but I had been
    socialized by K&R and it obviously left its traces.

    Usually I prefer languages and compilers to tell me whenever I pass
    a value that isn't matching the type.

    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 Mon Aug 17 03:48:22 2026
    David Brown <david.brown@hesbynett.no> writes:
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    [...]
    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.

    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    Sure, but the advantage isn't applicable in this case. If ipow's
    second parameter is unsigned, ipow(n, -1) is going to overflow,
    not compute 1/n.

    --
    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 Mon Aug 17 04:25:46 2026
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    David Brown <david.brown@hesbynett.no> writes:
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    [...]
    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.

    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    Sure, but the advantage isn't applicable in this case. If ipow's
    second parameter is unsigned, ipow(n, -1) is going to overflow,
    not compute 1/n.

    Well, it's not going to overflow if n is -1 or 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 David Brown@3:633/10 to All on Mon Aug 17 13:44:27 2026
    On 17/08/2026 13:25, Keith Thompson wrote:
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
    David Brown <david.brown@hesbynett.no> writes:
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    [...]
    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.

    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    Sure, but the advantage isn't applicable in this case.

    Agreed.

    If ipow's
    second parameter is unsigned, ipow(n, -1) is going to overflow,
    not compute 1/n.

    Well, it's not going to overflow if n is -1 or 1.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Mon Aug 17 21:37:42 2026
    On 17/08/2026 2:37 PM, Lawrence D?Oliveiro wrote:
    On Thu, 13 Aug 2026 18:10:12 +0200, Bonita Montero wrote:

    It makes code less readable for nearly no gain.

    Both C and C++ programmers seem to have this philosophy of ?if in
    doubt, add more parentheses?.

    Lawrence, what are you talking about? Of course we don't. I code in
    both C -- and well, sometimes -- C++ so I'll count my weight in this statistical example as double those of other programmers, and tell you
    once and for all, that we don't add parenthesis. That's what we do in comp.lang.lisp.

    What we do instead, is to remove parenthesis, and see what happens. For instance, I'm sure you had no idea people could trivially keep their
    types in sync when malloc()ing, by not using parenthesis at all.

    struct foo { int a, b ; } ;
    struct foo *f = malloc( sizeof *f ) ;

    And now, we not only remove the superfluous parenthesis after sizeof, we
    also make sure that if we change the type of f, the size malloc() ret-
    urns* changes with it.

    Simple, isn't it? And since this is comp.lang.c, and not comp.lang.c++,
    we keep foo in the struct namespace. See, C has namespaces, and always
    has. Well, for some value of always, as there's a reason the Posix
    standard has all these struct fields with names that mimic the name of
    the struct itself.

    So, what I'm getting at, Lawrence, is that here in comp.lang.c, we re-
    move superfluous parenthesis left by other programmers, and remove them.

    /All/. /Of/. /Them/.


    Happy remove parenthesis pull requests!


    * No, this is not an urn. For that, you go to the Egyptological depart-
    ment.
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Mon Aug 17 21:40:56 2026
    On 17/08/2026 2:40 PM, Lawrence D?Oliveiro wrote:
    On Thu, 13 Aug 2026 19:07:02 -0500, Lynn McGuire wrote:

    I would rather see a standard user interface toolkit for C++ first.

    With only one exception I?m aware of, there is no standard UI toolkit
    for *any* cross-platform language, for obvious reasons.

    What are you talking about? You're running your mouth off again, with-
    out having the faintest clue what you're talking about. There is a
    standard UI toolkit, and it's called IUP, and exists for all major 2D
    graphical operating systems.


    Though interestingly, there has been a proposal knocking around among
    the C++ standardization committee for some years for a standard 2D
    graphics API. Like the one that has been incorporated in JavaScript,
    this one is also based on Cairo <https://www.cairographics.org/>, but
    unlike that, it seems to be even less complete, omitting even text functionality.

    Yes, that's a failure of the C++ committee. They just can't admit to themselves that the very best UI toolkit out there is meant for C pro- grammers.

    Otherwise, they'd have standardized IUP decades ago!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 17 14:26:58 2026
    David Brown <david.brown@hesbynett.no> writes:
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    On 2026-08-16 21:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:
    [...]

    But his posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a
    fix for those cases, I agree that his algorithm is fine.

    Actually, programming lots of Algol68 lately, I used a few patterns
    from that language also in my iterative code. (I had mentioned the
    unnecessary use of the "base" variable, and the 'int' parameter was
    also a remains.) In "C" (and forgetting Algol 68 for a moment) I'd
    probably have written it more "C-ish"; i.e. using an 'unsigned int'
    for the parameter 'n' to more clearly define its range as positive,
    operating directly on 'a', and condensing the 'while' loop by 'for'.

    long int ipow (long int a, unsigned int n)
    {
    ÿÿÿ long int res = 1;
    ÿÿÿ for ( ; n > 0; n /= 2) {
    ÿÿÿÿÿÿÿ if (n & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ res *= a;
    ÿÿÿÿÿÿÿ a *= a;
    ÿÿÿ }
    ÿÿÿ return res;
    }

    The "n < 0" case can then also be omitted completely and adds to its
    brevity.

    That was my thought, yes.


    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.


    Some people see that as an advantage - being able to write "unsigned >very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.


    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    --- 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 Aug 17 16:58:09 2026
    On 17/08/2026 16:26, Scott Lurndal wrote:
    David Brown <david.brown@hesbynett.no> writes:
    On 17/08/2026 03:32, Janis Papanagnou wrote:
    On 2026-08-16 21:30, David Brown wrote:
    On 16/08/2026 18:35, Janis Papanagnou wrote:
    [...]

    But his posted algorithm is sound, I'd say.

    With the addition of documentation about negative "n" being UB, or a
    fix for those cases, I agree that his algorithm is fine.

    Actually, programming lots of Algol68 lately, I used a few patterns
    from that language also in my iterative code. (I had mentioned the
    unnecessary use of the "base" variable, and the 'int' parameter was
    also a remains.) In "C" (and forgetting Algol 68 for a moment) I'd
    probably have written it more "C-ish"; i.e. using an 'unsigned int'
    for the parameter 'n' to more clearly define its range as positive,
    operating directly on 'a', and condensing the 'while' loop by 'for'.

    long int ipow (long int a, unsigned int n)
    {
    ÿÿÿ long int res = 1;
    ÿÿÿ for ( ; n > 0; n /= 2) {
    ÿÿÿÿÿÿÿ if (n & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ res *= a;
    ÿÿÿÿÿÿÿ a *= a;
    ÿÿÿ }
    ÿÿÿ return res;
    }

    The "n < 0" case can then also be omitted completely and adds to its
    brevity.

    That was my thought, yes.


    I'd suppose the 'unsigned' wouldn't prevent a "C" user to nonetheless
    feed the 'ipow' function with '-1', but that's C's inherent problem.


    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.


    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    That makes more sense to me, but I can also see how some people find it
    a bit ugly or unclear. I almost invariably know exactly what size my
    types are (fixed-size types are the norm in my type of coding), so
    explicit values are my preference in most cases.



    --- 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 Mon Aug 17 10:07:05 2026
    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve. For me, 200 points
    is the point where diminishing returns has set in. Of course,
    YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not talk
    at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    --- 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 Mon Aug 17 10:22:44 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-16 16:33, Tim Rentsch wrote:

    bart <bc@freeuk.com> writes:

    [a C version of someone's ipow() function]

    long long int ipow(long long a, int n) {
    long long int res;

    res = 1;
    if (n < 0) {
    res = 0;

    } else if (n == 0) {
    res = 1;

    } else if (n == 1) {
    res = a;

    } else if ((n & 1) == 0) { // n is even
    res = ipow(a*a, n/2);

    } else { // n is odd
    res = ipow(a*a, (n-1)/2)*a;
    }

    return res;
    }

    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    I find it easier simply to write a properly tail-recursive
    implementation from the outset, where I know compilers will have
    no difficulty optimizing out the tail calls.

    Two: it gets wrong answers for in some cases with negative
    exponents.

    Ah, a typical non-answer! - Given that negative exponents are (here) generally handled to provide a result of 0 - and assuming that is
    accepted as result, since other libraries may provide an exception
    or error here - what are these "some cases with negative exponents"
    you have in mind; if you are so deign to give an answer this time.

    What is typical is your usual fractious misdirection style. You
    might consider trying to lower your talking-to-thinking ratio.

    --- 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 Mon Aug 17 19:49:22 2026
    On 2026-08-17 19:22, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-16 16:33, Tim Rentsch wrote:

    [...]

    Ah, a typical non-answer! - [...]

    What is typical is your usual fractious misdirection style. You
    might consider trying to lower your talking-to-thinking ratio.

    I suppose you're too old to expose a sane level of self-reflection.
    And hypocritical as well. Just in your recent post you complained
    about "an overly long thread" and regularly contribute non-answers.
    You might consider thinking and reflecting about your own posts
    and socio-pathological behavior before suggesting others what they
    should do. Good luck!

    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 Mon Aug 17 20:00:38 2026
    On 2026-08-17 19:22, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-16 16:33, Tim Rentsch wrote:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    I find it easier simply to write a properly tail-recursive
    implementation from the outset,

    Fair enough.

    where I know compilers will have
    no difficulty optimizing out the tail calls.

    Not all might know whether and what sorts of constructs their
    compilers are able to optimize. To me it's not obvious that
    simple (but non-tail-) recursions are typically not optimized.
    YMMV, but sensible optimizations is IMO task of the compilers;
    it shouldn't be necessary that you have to formulate programs
    using a specific programming pattern; ideally - but "C" as had
    been discussed not long ago exposes anyway a peculiar view of
    optimizations. (I'm sure YMMV.)

    Janis


    --- 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 Aug 17 20:37:13 2026
    On 17/08/2026 20:00, Janis Papanagnou wrote:
    On 2026-08-17 19:22, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-16 16:33, Tim Rentsch wrote:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    I find it easier simply to write a properly tail-recursive
    implementation from the outset,

    Fair enough.

    where I know compilers will have
    no difficulty optimizing out the tail calls.

    Not all might know whether and what sorts of constructs their
    compilers are able to optimize. To me it's not obvious that
    simple (but non-tail-) recursions are typically not optimized.
    YMMV, but sensible optimizations is IMO task of the compilers;
    it shouldn't be necessary that you have to formulate programs
    using a specific programming pattern; ideally - but "C" as had
    been discussed not long ago exposes anyway a peculiar view of
    optimizations. (I'm sure YMMV.)


    You are correct - it is not at all obvious when a compiler might be able
    to figure out a loop version of a recursive function. In this case, gcc
    and clang managed to do so with the code as-is. And there are plenty of compilers (or compiler option choices) that cannot manage any kind of
    tail recursion optimisation. But it is possible to increase the chances
    of tail recursion optimisation being applied, by writing code in an appropriate style.

    As I noted earlier, it will make very little difference in this case
    because the recursion depth is not going to me more than a couple of
    levels anyway.


    --- 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 Mon Aug 17 14:48:31 2026
    On 8/15/2026 12:40 PM, Ross Finlayson wrote:
    On 08/14/2026 08:51 PM, Lynn McGuire wrote:
    On 8/14/2026 9:24 PM, Chris M. Thomasson wrote:
    On 8/14/2026 2:40 PM, Lynn McGuire wrote:
    On 8/14/2026 3:51 PM, Chris M. Thomasson wrote:
    On 8/14/2026 1:48 PM, Lynn McGuire wrote:
    On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:
    On 8/13/2026 10:58 PM, Lynn McGuire wrote:
    On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:
    On 8/13/2026 4:59 PM, Lynn McGuire wrote:
    [...]
    Mine is coming from a chemical process simulator where
    chemicals are moving between the four phases of matter that we >>>>>>>>>> support: vapor, hydrocarbon liquid, aqueous liquid, and solids, >>>>>>>>>> based on temperature and pressure.ÿ The tables are incredibly >>>>>>>>>> non-linear.

    This is my people and I:
    ÿÿÿ https://www.winsim.com/

    Notice any fractal growth in there?

    We don't do that.
    Let me clarify... Do you make renders of a simulation? If so, do >>>>>>> some of them look fractal?

    In short, no.ÿ We have a diagrammatic user interface that allows
    our users to build a diagram of a chemical process flow diagram
    such as a refinery, a natural gas plan, a pipeline with compressor >>>>>> stations, or a chemical plant.
    ÿÿÿ https://www.winsim.com/screenshots.html

    And we have a calculation engine that takes a textual version of
    that diagram and solves it thermodynamically.ÿ If, it can be solved >>>>>> as not all chemical processes can be solved due to constraints or
    violation of the laws of thermodynamics.
    Ahhhh! So, you are not making any animations of the processes. Okay. >>>>> But you have the data to do so...

    Fwiw, I bet you already have the data to make one of my 2d examples
    here:

    https://youtu.be/YS-tyDJVy4M

    Actually, I do make an animation of the process simulation diagram
    (PSD).

    Can you give me a link to some screenshots so I can get on the same
    page? Thanks. Are you almost done with your Fortran port?
    ...

    https://www.winsim.com/screenshots.html

    I am about 1/3rd of the way done with my 800,000 lines of F77 code to
    C++ code.ÿ My custom version of F2C is doing about 60 to 70% of the
    work.ÿ I am equating the task as equivalent to translating about ten
    long engineering books from German to French.ÿ Lots of idioms and basic
    incompatibilities that have to be ironed out.

    I was shooting for the end of 2026 but that ship has sailed.ÿ Maybe
    middle of 2027.ÿ Then I have to port to x64 but the port should be easy
    (he says with the ship sitting in ten feet of mud in the harbor).

    Lynn


    Translating the idioms right makes for "naturals" alignment and storage,
    and so on. Then the numerical methods one imagines are
    involved in solving linearities for invariants and process control,
    then that's involved itself, and the relevance of the compatibility
    of the numerical methods, for their mathematical guarantees, for
    their physical estimates, about how many traincars and truckloads
    of feeder stock under what conditions and augury make diapers or
    galoshes or legos or condoms or pipe or contact lenses or lacquer
    or petrochemicals or drugs or otherwise usually enough more refined
    materials from more raw materials.

    Here it's like "measure-twice cut-once" the old "build a fence
    a mile, could you move it a foot?"

    If the great difference for FORTRAN and C is the account of
    the column-major or row-major and that of arrays and loops,
    then besides a simplest sort of transpose, or organization
    and alignment and storage, then is for the model of computation
    the entry-points and the state & scope, the modules, point being here
    it's perceived as a quite impressive and thoroughgoing sort of
    account of quite very much the value the algorithms and numerical
    methods express as models of control theory.

    The Bessemer furnace, ....

    https://en.wikipedia.org/wiki/Bessemer_process

    Then, there was mentioned "violations of the thermo second law",
    or rather, "accommodations to effects of resonance theory",
    these sorts acconts of "effects", which are basically anything
    outside otherwise the theory, or "exceptions", yes one imagines
    that those make for the accounts of state & scope the quite
    complicated, which for example "exception specification" provides
    in higher-level languages with exception specification as a critical component of safety in the modules of software, quite invokes the deliberations of "why" instead of merely "because".


    The, "term-rewriting", or a bit more holistically the
    "term-graph-rewriting", is definitely a thing in software since that "generative programming" is a term from the 1960's, and "program
    translation" is is quite usual, then for "models of computation"
    and "modules of computation".


    Long story short such an endeavor is perceived to be a store of
    great _value_, and such porting effort is quite a study of both
    the numerical methods, which as usually approximations need
    their error-bounds modeled, like Runge-Kutta for example after
    Gregory & Coates as Newton's, or about Leontief and so on,
    numerical methods and linear systems and linear solvers,
    then with regards to standard and empirical units, which are
    not necessarily the same and where regimes of effect are
    according to their own units, good luck with that, it sounds
    like something vital to the real-world economy.
    Sorry, I lost you in the first part of your reply. If you are saying
    that it is a tough translation, yes it is. Especially since much of our Fortran was written back in the middle 1960s with Fortran II and Fortran
    IV (66). We did not convert to Fortran 77 until 1995 or so due to the
    2X cost to compile code on the mainframes using the F77 compiler instead
    of the F66 compiler. And the source code is mostly uncommented since we
    paid a penny a line / time period (day ? month ? year?) to store the
    source code on the Univac 1108.

    The worst part of the translation is converting from arrays starting at
    one to arrays starting at zero. My translation tool is converting all
    of the multiple dimensioned arrays to single dimensioned arrays for me
    to get out of the array ordering issues.

    I am equating the translation to converting a dozen highly technical
    books written in German to French.

    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 Mon Aug 17 14:56:59 2026
    On 8/16/2026 5:49 PM, Lawrence D?Oliveiro wrote:
    On Fri, 14 Aug 2026 13:54:54 -0500, Lynn McGuire wrote:

    BTW, in Smalltalk you can return any type of object from a method.
    But if the caller got a weird object back, it was a place of
    confusion and often a crash as the expected object type was not the
    actual object type.

    I way prefer strongly typed languages now.

    Smalltalk IS ?strongly typed?. I think you mean ?statically typed?, as opposed to ?dynamically typed?.
    ...
    Our particular variant of Smalltalk, Whitewater Actor, was not strongly
    typed. You could have a var calling any gibberish that you called a
    method and it was not linked until runtime with the subsequent crash.
    https://en.wikipedia.org/wiki/Actor_(programming_language)

    The only thing that I miss about Smalltalk is the casual heterogeneous collections. Those were immensely useful. I built several classes in
    C++ to model them with a common ancestor class but never got the same
    effect.

    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 Mon Aug 17 15:17:12 2026
    On 8/16/2026 5:49 PM, Lawrence D?Oliveiro wrote:
    On Fri, 14 Aug 2026 13:54:54 -0500, Lynn McGuire wrote:

    BTW, in Smalltalk you can return any type of object from a method.
    But if the caller got a weird object back, it was a place of
    confusion and often a crash as the expected object type was not the
    actual object type.

    I way prefer strongly typed languages now.

    Smalltalk IS ?strongly typed?. I think you mean ?statically typed?, as opposed to ?dynamically typed?.

    So, all objects had to have a common set of methods (read, write,
    print, add, etc) to keep weird crashes from happening. I ended up
    putting all methods at an object and the base object too. Our base
    object had hundreds of methods to handle weird cases.

    Shouldn?t you have cleaned up the code to deal properly with the
    different object types?
    ...

    Yup. My employees and I converted all of the Smalltalk code to C++
    using a Act2Cpp translator that I wrote. Works like a champ and runs
    120X faster. Yes, I timed the old code versus the new code.

    The C++ code was more verbose. 250,000 lines of Smalltalk converted to 450,000 lines of C++. Tough tookie, the speed was everything. And
    Win32 instead of Win16. Some of my customers are using datasets over a gigabyte in size so we are moving to Win64 soon as soon as my employee finishes the Unicode port, the first version of the software ran under
    Windows 2.0.

    Lynn


    --- 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 Aug 18 00:35:01 2026
    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve. For me, 200 points
    is the point where diminishing returns has set in. Of course,
    YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not
    talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve Cryptography
    (ECC). In this field it's worth spending much more than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although not dramatically wider, IIRC, 192 bits are considered good enough in many real-world applications) and arithmetic is modular.


    --- 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 Mon Aug 17 16:49:34 2026
    scott@slp53.sl.home (Scott Lurndal) writes:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    Some people see that as an advantage - being able to write "unsigned >>very_big = -1;". I dislike it personally, but styles and preferences >>vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    I'd use ~0ul to get all-ones, -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    The fact that they happen to be the same value is a technical detail
    that I don't necessarily want to worry about. Whether I use ~0ul
    or -1 depends on which concept I want to express.

    --
    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 Mon Aug 17 23:53:19 2026
    On Mon, 17 Aug 2026 14:56:59 -0500, Lynn McGuire wrote:

    On 8/16/2026 5:49 PM, Lawrence D?Oliveiro wrote:

    On Fri, 14 Aug 2026 13:54:54 -0500, Lynn McGuire wrote:

    BTW, in Smalltalk you can return any type of object from a method.
    But if the caller got a weird object back, it was a place of
    confusion and often a crash as the expected object type was not
    the actual object type.

    I way prefer strongly typed languages now.

    Smalltalk IS ?strongly typed?. I think you mean ?statically typed?,
    as opposed to ?dynamically typed?.
    ...
    Our particular variant of Smalltalk, Whitewater Actor, was not
    strongly typed. You could have a var calling any gibberish that you
    called a method and it was not linked until runtime with the
    subsequent crash.
    https://en.wikipedia.org/wiki/Actor_(programming_language)

    Ah, I see. Looks like they were relying on a generic machine-code
    linker to tie things together, instead of having their own
    language-specific linking layer to avoid accidents like this.

    The only thing that I miss about Smalltalk is the casual
    heterogeneous collections. Those were immensely useful. I built
    several classes in C++ to model them with a common ancestor class
    but never got the same effect.

    Is that just a list or table where the entries can have any type?
    That?s a standard thing in any dynamic language, surely.

    --- 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 Mon Aug 17 19:59:50 2026
    On 8/17/2026 6:53 PM, Lawrence D?Oliveiro wrote:
    On Mon, 17 Aug 2026 14:56:59 -0500, Lynn McGuire wrote:

    On 8/16/2026 5:49 PM, Lawrence D?Oliveiro wrote:

    On Fri, 14 Aug 2026 13:54:54 -0500, Lynn McGuire wrote:

    BTW, in Smalltalk you can return any type of object from a method.
    But if the caller got a weird object back, it was a place of
    confusion and often a crash as the expected object type was not
    the actual object type.

    I way prefer strongly typed languages now.

    Smalltalk IS ?strongly typed?. I think you mean ?statically typed?,
    as opposed to ?dynamically typed?.
    ...
    Our particular variant of Smalltalk, Whitewater Actor, was not
    strongly typed. You could have a var calling any gibberish that you
    called a method and it was not linked until runtime with the
    subsequent crash.
    https://en.wikipedia.org/wiki/Actor_(programming_language)

    Ah, I see. Looks like they were relying on a generic machine-code
    linker to tie things together, instead of having their own
    language-specific linking layer to avoid accidents like this.

    The only thing that I miss about Smalltalk is the casual
    heterogeneous collections. Those were immensely useful. I built
    several classes in C++ to model them with a common ancestor class
    but never got the same effect.

    Is that just a list or table where the entries can have any type?
    That?s a standard thing in any dynamic language, surely.

    Yup. Smalltalk had Dictionary, Bag, and Map. All heterogeneous.

    Lynn


    Lynn


    --- 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 Tue Aug 18 02:47:31 2026
    On Mon, 17 Aug 2026 19:59:50 -0500, Lynn McGuire wrote:

    On 8/17/2026 6:53 PM, Lawrence D?Oliveiro wrote:

    On Mon, 17 Aug 2026 14:56:59 -0500, Lynn McGuire wrote:

    The only thing that I miss about Smalltalk is the casual
    heterogeneous collections. Those were immensely useful. I built
    several classes in C++ to model them with a common ancestor class
    but never got the same effect.

    Is that just a list or table where the entries can have any type?
    That?s a standard thing in any dynamic language, surely.

    Yup. Smalltalk had Dictionary, Bag, and Map. All heterogeneous.

    Python has actual expressions you can use to build those in the
    language itself. E.g. from <https://gitlab.com/ldo/dbussy>:

    standard_interfaces = \
    {
    DBUS.INTERFACE_PEER :
    # note implementation of this is hard-coded inside libdbus
    Introspection.Interface
    (
    name = DBUS.INTERFACE_PEER,
    methods =
    [
    Introspection.Interface.Method(name = "Ping"),
    Introspection.Interface.Method
    (
    name = "GetMachineId",
    args =
    [
    Introspection.Interface.Method.Arg
    (
    name = "machine_uuid",
    type = BasicType(TYPE.STRING),
    direction = Introspection.DIRECTION.OUT,
    ),
    ]
    ),
    ],
    ),
    DBUS.INTERFACE_LOCAL :
    # note implementation of this is hard-coded inside, and specific to, libdbus
    Introspection.Interface
    (
    name = DBUS.INTERFACE_LOCAL,
    signals =
    [
    Introspection.Interface.Signal(name = "Disconnected"),
    # auto-generated by libdbus with path = DBUS.PATH_LOCAL
    # when connection is closed; cannot be explicitly sent by
    # clients. Documented here:
    # <https://lists.freedesktop.org/archives/dbus/2018-October/017587.html>
    ],
    ),
    ...
    }

    --- 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 Tue Aug 18 00:42:58 2026
    On 8/11/2026 3:01 AM, Lynn McGuire wrote:
    Why is there not a ipow version of pow?

    ipow would return an int instead of a double.ÿ Or a long long int.

    Thanks,
    Lynn

    Here is my code to date (longint is long long int):

    // ipow.cpp

    // calculate an longint power of a longint number

    // INPUT:
    // base - longint value of number
    // exp - longint
    // OUTPUT:
    // longint value of base to the exp power

    // REVISIONS:
    // ==========
    // 08/11/26 Lynn McGuire created using
    // https://stackoverflow.com/questions/101439/the-most-efficient-way-to-implement-an-integer-based-power-function-powint-int

    #include "dii.h"

    longint ipow (longint base, longint exp)
    {
    longint result = 1;
    std::string str;

    if (exp == 0 || base == 0) {
    return result;
    }

    if (exp < 0) {
    scrwri ("");
    str = "ERROR: exp is negative, " + asString (exp) + " (ipow)";
    scrwri (str);
    scrwri ("");
    quit ();
    return 0;
    }

    for (;;)
    {
    if (exp & 1)
    result *= base;
    exp >>= 1;
    if (!exp)
    break;
    base *= base;
    }

    return result;
    } /* ipow */

    Thanks,
    Lynn


    --- 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 Tue Aug 18 09:34:32 2026
    Am 18.08.2026 um 07:42 schrieb Lynn McGuire:

    longint ipow (longint base, longint exp)
    {
    ÿÿÿÿlongint result = 1;
    ÿÿÿÿstd::string str;

    ÿÿÿÿif (exp == 0 || base == 0) {
    ÿÿÿÿÿÿÿ return result;
    ÿÿÿÿ}

    ÿÿÿÿif (exp < 0) {
    ÿÿÿÿÿÿÿ scrwri ("");
    ÿÿÿÿÿÿÿ str = "ERROR: exp is negative, " + asString (exp) + " (ipow)";
    ÿÿÿÿÿÿÿ scrwri (str);
    ÿÿÿÿÿÿÿ scrwri ("");
    ÿÿÿÿÿÿÿ quit ();
    ÿÿÿÿÿÿÿ return 0;
    ÿÿÿÿ}

    If x is negative and base is zero you get an infinite result. If base
    is +/-1 you get a result of +/-1, depending on if the exponent is odd
    or not. If abs( base ) is > 1 you get zero.


    ÿÿÿÿfor (;;)
    ÿÿÿÿ{
    ÿÿÿÿÿÿÿ if (exp & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ result *= base;
    ÿÿÿÿÿÿÿ exp >>= 1;
    ÿÿÿÿÿÿÿ if (!exp)
    ÿÿÿÿÿÿÿÿÿÿÿ break;
    ÿÿÿÿÿÿÿ base *= base;
    ÿÿÿÿ}

    You've to check exp at the begining. And it's better to have an
    overflow detection. But this is possible only with unsigned values
    since the compiler can assume that signeds don't overflow.

    ÿÿÿÿreturn result;
    }ÿ /* ipow */


    --- 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 Aug 18 11:22:32 2026
    On 17/08/2026 23:35, Michael S wrote:
    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best when
    performing a numerical integration of a curve. For me, 200 points
    is the point where diminishing returns has set in. Of course,
    YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not
    talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve Cryptography (ECC). In this field it's worth spending much more than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although not dramatically wider, IIRC, 192 bits are considered good enough in many real-world applications) and arithmetic is modular.


    Sure - but the key pointer there is that the arithmetic is modular. A
    modular ipower() function is quite different from a non-modular one, and
    used with very different values. I'd imagine a great deal of effort
    goes into making them efficient for cryptography (ECC, RSA, etc.)



    --- 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 Aug 18 11:32:22 2026
    On 18/08/2026 07:42, Lynn McGuire wrote:
    On 8/11/2026 3:01 AM, Lynn McGuire wrote:
    Why is there not a ipow version of pow?

    ipow would return an int instead of a double.ÿ Or a long long int.

    Thanks,
    Lynn

    Here is my code to date (longint is long long int):

    //ÿ ipow.cpp

    //ÿ calculate an longint power of a longint number

    //ÿ INPUT:
    //ÿÿÿÿ base - longint value of number
    //ÿÿÿÿ exp - longint
    //ÿ OUTPUT:
    //ÿÿÿÿ longint value of base to the exp power

    // REVISIONS:
    // ==========
    //ÿ 08/11/26ÿ Lynn McGuireÿ created using
    // https://stackoverflow.com/questions/101439/the-most-efficient-way-to- implement-an-integer-based-power-function-powint-int

    #include "dii.h"

    longint ipow (longint base, longint exp)
    {
    ÿÿÿÿlongint result = 1;
    ÿÿÿÿstd::string str;

    ÿÿÿÿif (exp == 0 || base == 0) {
    ÿÿÿÿÿÿÿ return result;
    ÿÿÿÿ}

    ÿÿÿÿif (exp < 0) {
    ÿÿÿÿÿÿÿ scrwri ("");
    ÿÿÿÿÿÿÿ str = "ERROR: exp is negative, " + asString (exp) + " (ipow)";
    ÿÿÿÿÿÿÿ scrwri (str);
    ÿÿÿÿÿÿÿ scrwri ("");
    ÿÿÿÿÿÿÿ quit ();
    ÿÿÿÿÿÿÿ return 0;
    ÿÿÿÿ}

    ÿÿÿÿfor (;;)
    ÿÿÿÿ{
    ÿÿÿÿÿÿÿ if (exp & 1)
    ÿÿÿÿÿÿÿÿÿÿÿ result *= base;
    ÿÿÿÿÿÿÿ exp >>= 1;
    ÿÿÿÿÿÿÿ if (!exp)
    ÿÿÿÿÿÿÿÿÿÿÿ break;
    ÿÿÿÿÿÿÿ base *= base;
    ÿÿÿÿ}

    ÿÿÿÿreturn result;
    }ÿ /* ipow */


    It seems odd to have a run-time check for the very unlikely case of a
    negative exponent, and no run-time check for overflow.

    You should also drop the C90 "declare all variables at the top of the function" style. It's a bad idea in C, and a terrible idea in C++. You
    don't want to be unnecessarily creating a std::string object and running
    its constructor and destructor in a function that should be fast.
    Instead, put the declaration where it is needed :

    const std::string str = "ERROR ..."

    I don't know if you are using exceptions in your code base, but if you
    are, they would be a better choice here. Then your function could be
    made "constexpr" as well as being more efficient in the normal case.


    --- 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 Aug 18 08:38:43 2026
    Michael S <already5chosen@yahoo.com> writes:

    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did
    not talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.

    For the function originally being asked about, where the operations
    are being done on basic integer types, I think 15 minutes (or so)
    should be enough.

    For applications like Elliptic Curve Cryptography, where the values
    are multiple-precision integers rather than basic integer types, the
    same algorithm should be okay, except that attention needs to be
    given to the (modulo-ized) multi-precision multiplications used.
    The bottleneck is multiplications, not the overall algorithm
    structure.

    As an experiment I took the C implementation I first wrote (which
    had taken five or ten minutes) and wrote the same algorithm in
    python, except that multiplications were done mod 2**192. I ran
    trials with that, including for example

    >>> ipow( 97, 33333333333333333333333333333333333333333333333333333333333 )
    5528880020554650661730432042596473300798439881536715294689

    All the trial invocations returned instantly. So I don't think the
    original basic algorithm needs to be changed; as long as care is
    given to how the multiplications are done (which python does a fair
    job at, for this size of operands), a simple implementation should
    be okay even for applications like ECC.

    --- 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 Tue Aug 18 16:33:45 2026
    bart <bc@freeuk.com> wrote:
    On 13/08/2026 00:52, Lawrence D?Oliveiro wrote:
    On Wed, 12 Aug 2026 11:28:34 +0100, bart wrote:

    It is certainly convenient to be able to write 2**32 instead of
    1<<32, where it is so easy to write 2<<32 by mistake.

    Doesn?t seem any more likely than writing ?1**32? though, does it?

    Actually it is. I've done it quite a few times. The point of 1<<N is to
    end up with a value of 2**N (ie. a value with only bit N set). But if
    the language allows you to write 2**N anyway, then there's no need to
    use an error prone workaround.

    Depends on your mindset. When I want bit N set, then I use shift
    if available. 2**N is for languages which lack shifts. I am quite
    adept at writing or reading code which use powers to get shifted bits,
    but AFAICS it is more error prone than using shifts.

    Power is approptiate when power is wanted, but in C I rarely use
    powers and cases when base is fixed and equal 2 are even more rare.

    --
    Waldek Hebisch

    --- 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 Aug 18 22:17:40 2026
    On Tue, 18 Aug 2026 08:38:43 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did
    not talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.

    For the function originally being asked about, where the operations
    are being done on basic integer types, I think 15 minutes (or so)
    should be enough.

    For applications like Elliptic Curve Cryptography, where the values
    are multiple-precision integers rather than basic integer types, the
    same algorithm should be okay, except that attention needs to be
    given to the (modulo-ized) multi-precision multiplications used.
    The bottleneck is multiplications, not the overall algorithm
    structure.

    As an experiment I took the C implementation I first wrote (which
    had taken five or ten minutes) and wrote the same algorithm in
    python, except that multiplications were done mod 2**192. I ran
    trials with that, including for example

    >>> ipow( 97,
    >>> 33333333333333333333333333333333333333333333333333333333333 )
    5528880020554650661730432042596473300798439881536715294689

    All the trial invocations returned instantly. So I don't think the
    original basic algorithm needs to be changed; as long as care is
    given to how the multiplications are done (which python does a fair
    job at, for this size of operands), a simple implementation should
    be okay even for applications like ECC.


    In my real world case the target was 32-bit microcontroller-class soft
    core without hardware multiplier running at 100 MHz. Also, we should not
    forget that a single ECDSA signature validation contains plenty of
    ipow() steps. Right now I don't remember how many.

    I didn't try algorithm presented here by Bart, but tried something that
    can be seen as its mirror image.

    wword ipow(wword a, wword n)
    {
    if (n < 2)
    return n == 0 ? 1 : a;

    wword y = ipow(a, n/2);
    y *= y;
    if (n & 1)
    y *= a;
    return y;
    }

    Please, treat it as a pseudocode.
    Real code was more complicated, with function calls instead of *
    and recursion was manually converted to iteration.

    The result was slower than the following (pseudo) code:

    wword ipow(wword a, wword n)
    {
    wword y = 1, p = a;
    while (1) {
    if (n & 1)
    y *= p;
    n /= 2;
    if (!n)
    break;
    p *= p;
    }
    return y;
    }

    I didn't try to investiagete reasons for the difference.









    --- 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 Aug 18 22:22:39 2026
    On Tue, 18 Aug 2026 11:22:32 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    On 17/08/2026 23:35, Michael S wrote:
    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not
    talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.


    Sure - but the key pointer there is that the arithmetic is modular.
    A modular ipower() function is quite different from a non-modular
    one, and used with very different values. I'd imagine a great deal
    of effort goes into making them efficient for cryptography (ECC, RSA,
    etc.)



    The only big difference that modular makes is that with non-modular you
    can safely assume that big values of n do not matter (except of
    trivial cases of a = 0 or 1).
    Apart from that it's quite similar.





    --- 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 Aug 18 21:59:22 2026
    On 18/08/2026 21:22, Michael S wrote:
    On Tue, 18 Aug 2026 11:22:32 +0200
    David Brown <david.brown@hesbynett.no> wrote:

    On 17/08/2026 23:35, Michael S wrote:
    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did not
    talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.


    Sure - but the key pointer there is that the arithmetic is modular.
    A modular ipower() function is quite different from a non-modular
    one, and used with very different values. I'd imagine a great deal
    of effort goes into making them efficient for cryptography (ECC, RSA,
    etc.)



    The only big difference that modular makes is that with non-modular you
    can safely assume that big values of n do not matter (except of
    trivial cases of a = 0 or 1).
    Apart from that it's quite similar.


    I don't know the details of ECC implementations, so I may be asking
    silly questions here. I suppose you can do the modulo operation as a
    multiply by the scaled reciprocal, as compilers generally do when
    dividing by a compile-time constant. This reciprocal only needs to be calculated once - after that, it's all just multiplies. Is that correct?


    --- 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 Aug 18 20:26:00 2026
    In article <864igs3bmj.fsf@linuxsc.com>,
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-16 16:33, Tim Rentsch wrote:
    [snip]
    Two observations:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    I find it easier simply to write a properly tail-recursive
    implementation from the outset, where I know compilers will have
    no difficulty optimizing out the tail calls.

    At the language level, C does not guarantees tail optimization
    of recursive calls. Thus, the idea of writing, "a proper
    tail-recursive implementation from the outset" is a non
    sequitur. At best, expecting tail call optimization in a C
    program would be highly dependent on the translation
    environment.

    - Dan C.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Johann 'Myrkraverk' Oskarsson@3:633/10 to All on Wed Aug 19 04:53:57 2026
    On 18/08/2026 11:38 PM, Tim Rentsch wrote:
    Michael S <already5chosen@yahoo.com> writes:

    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did
    not talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.

    For the function originally being asked about, where the operations
    are being done on basic integer types, I think 15 minutes (or so)
    should be enough.

    For applications like Elliptic Curve Cryptography, where the values
    are multiple-precision integers rather than basic integer types, the
    same algorithm should be okay, except that attention needs to be
    given to the (modulo-ized) multi-precision multiplications used.
    The bottleneck is multiplications, not the overall algorithm
    structure.

    As an experiment I took the C implementation I first wrote (which
    had taken five or ten minutes) and wrote the same algorithm in
    python, except that multiplications were done mod 2**192. I ran
    trials with that, including for example

    >>> ipow( 97, 33333333333333333333333333333333333333333333333333333333333 )
    5528880020554650661730432042596473300798439881536715294689

    All the trial invocations returned instantly. So I don't think the
    original basic algorithm needs to be changed; as long as care is
    given to how the multiplications are done (which python does a fair
    job at, for this size of operands), a simple implementation should
    be okay even for applications like ECC.

    Thank you, Tim. Now, for beginners like me, and who still like to code
    their own cryptography and/or multiprecision libraries, I heartily re-
    commend the books by Tom St Denis, /Bignum Math/, and /Cryptography for Developers/. When you chase down the references he cites, you'll also
    want /Handbook of Applied Cryptography/ by Menezes, van Ooorschot, and Vanstone; and /Applied Cryptography/ by Schneier et al.

    All of these books should be readily visible if you bother to check out
    my BlueSky profile. This comment is especially aimed at Chris M. Thoma-
    sson and others who don't believe I can do anything without invoking an
    L.L.M. to type for me. I'm perfectly capable of typing on my own!

    There are other books I can recommend for those who wish to go down the
    path of implementing E.C.C. on their own, but since implementing any-
    thing, anything at all seems to be anathema* here in comp.lang.c, I'll
    just leave it at that.


    Happy /elliptic curve cryptography/!

    * Yes, I know this word, you fuckwit Chris M. Thomasson!
    --
    Johann | email: invalid -> com | http://www.myrkraverk.com/blog/
    I'm not from the Internet, I just work there. | via Easynews.com https://bsky.app/profile/myrkraverk.bsky.social | for ( ;; ) _:;

    --- 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 Aug 18 15:42:54 2026
    Michael S <already5chosen@yahoo.com> writes:

    On Tue, 18 Aug 2026 08:38:43 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Mon, 17 Aug 2026 10:07:05 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Sat, 15 Aug 2026 13:00:22 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Lynn McGuire <lynnmcguire5@gmail.com> writes:

    I have found over the years that 200 points seems to be best
    when performing a numerical integration of a curve. For me,
    200 points is the point where diminishing returns has set in.
    Of course, YMMV.

    Surely that depends on which integration method is being used.

    That is smaller of my troubles with this post of Lynn.
    The bigger trouble is that my post, to which he "answered" did
    not talk at all about integration.

    Yeah. Not too surprising really, considering the general level
    of the discussion -- an overly long thread for a problem that
    should take at most 15 minutes to solve just by writing an
    ipow() function.

    Performance of ipow() is quite important in Elliptic Curve
    Cryptography (ECC). In this field it's worth spending much more
    than 15 minutes on optimization of this core primitive.
    Of course, in case of ECC integers are wider than 64-bit (although
    not dramatically wider, IIRC, 192 bits are considered good enough
    in many real-world applications) and arithmetic is modular.

    For the function originally being asked about, where the operations
    are being done on basic integer types, I think 15 minutes (or so)
    should be enough.

    For applications like Elliptic Curve Cryptography, where the values
    are multiple-precision integers rather than basic integer types, the
    same algorithm should be okay, except that attention needs to be
    given to the (modulo-ized) multi-precision multiplications used.
    The bottleneck is multiplications, not the overall algorithm
    structure.

    As an experiment I took the C implementation I first wrote (which
    had taken five or ten minutes) and wrote the same algorithm in
    python, except that multiplications were done mod 2**192. I ran
    trials with that, including for example

    >>> ipow( 97,
    >>> 33333333333333333333333333333333333333333333333333333333333 )
    5528880020554650661730432042596473300798439881536715294689

    All the trial invocations returned instantly. So I don't think the
    original basic algorithm needs to be changed; as long as care is
    given to how the multiplications are done (which python does a fair
    job at, for this size of operands), a simple implementation should
    be okay even for applications like ECC.

    In my real world case the target was 32-bit microcontroller-class
    soft core without hardware multiplier running at 100 MHz. Also,
    we should not forget that a single ECDSA signature validation
    contains plenty of ipow() steps. Right now I don't remember how
    many.

    I didn't try algorithm presented here by Bart, but tried something
    that can be seen as its mirror image.

    wword ipow(wword a, wword n)
    {
    if (n < 2)
    return n == 0 ? 1 : a;

    wword y = ipow(a, n/2);
    y *= y;
    if (n & 1)
    y *= a;
    return y;
    }

    Please, treat it as a pseudocode.
    Real code was more complicated, with function calls instead of *
    and recursion was manually converted to iteration.

    Huh. An unusual way of handling the recursive nature of the
    problem. It's not obvious to me how it works exactly.

    The result was slower than the following (pseudo) code:

    That isn't surprising, considering that the recursive call
    is not tail recursive.

    wword ipow(wword a, wword n)
    {
    wword y = 1, p = a;
    while (1) {
    if (n & 1)
    y *= p;
    n /= 2;
    if (!n)
    break;
    p *= p;
    }
    return y;
    }

    I didn't try to investiagete reasons for the difference.

    If I were to take a similar approach, I might write
    something like this (disclaimer: not compiled):

    wword
    xpow( wword a, wword n ){
    if( n < 2 ){
    // handle powers less than 2
    // exercise for the reader
    }

    wword r = 1;
    do {
    if( n & 1 ) r *= a;
    a *= a;
    } while( n /= 2, n > 1 );

    return r*a;
    }

    --- 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 Aug 18 17:44:10 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:

    If I were to take a similar approach, I might write
    something like this (disclaimer: not compiled):

    wword
    xpow( wword a, wword n ){
    if( n < 2 ){
    // handle powers less than 2
    // exercise for the reader
    }

    wword r = 1;
    do {
    if( n & 1 ) r *= a;
    a *= a;
    } while( n /= 2, n > 1 );

    return r*a;
    }

    Sorry about that.. darn tab characters..

    wword
    xpow( wword a, wword n ){
    if( n < 2 ){
    // handle powers less than 2
    // exercise for the reader
    }

    wword r = 1;
    do {
    if( n & 1 ) r *= a;
    a *= a;
    } while( n /= 2, n > 1 );

    return r*a;
    }

    --- 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 Aug 18 18:18:14 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-17 19:22, Tim Rentsch wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-16 16:33, Tim Rentsch wrote:

    One: one of the recursive calls is not properly tail recursive so
    the recursion isn't always optimized out.

    You could as well write that also from the beginning in an iterative
    form (and not rely on optimizations of recursive functions - in case
    that this is a problem for the compilers in mind).

    I find it easier simply to write a properly tail-recursive
    implementation from the outset,

    Fair enough.

    where I know compilers will have
    no difficulty optimizing out the tail calls.

    Not all might know whether and what sorts of constructs their
    compilers are able to optimize.

    I wasn't advising anyone else what to write; just saying what
    I would find easier.

    To me it's not obvious that
    simple (but non-tail-) recursions are typically not optimized.

    By always using a tail-recursive formulation I don't have to care
    about what other forms are optimized. As a rule when I write
    recursive calls that are not tail recursive I expect them to
    generate actual calls; I don't mind if such cases are optimized
    but I don't care if they aren't.

    YMMV, but sensible optimizations is IMO task of the compilers;
    it shouldn't be necessary that you have to formulate programs
    using a specific programming pattern;

    Perhaps I have given a wrong impression. I write code in a
    functional, and sometimes tail-recursive, style, not because I am
    thinking about whether it will be optimized but because I find it
    simple and natural and easy to understand. Of course I wouldn't
    do that if I thought it were going to perform badly, but I know
    from experience that it usually gets optimized to a non-recursive
    form.

    ideally - but "C" as had
    been discussed not long ago exposes anyway a peculiar view of
    optimizations. (I'm sure YMMV.)

    Tail call elimination has both a long history and a good theoretical underpinning. Part of why it is so attractive is that it's easy to
    accomplish; I've been aware of and making use of tail call
    elimination since the early 1970s. I don't find it surprising at
    all that C compilers (and also compilers for other languages)
    exploit the ease of effecting these transformation, not only to help
    runtime performance but also as a way of reducing pressure on stack
    size. It's like compilers recognizing that multiplying or dividing
    by powers of two can be turned into shifts -- it allows developers
    to write code in a natural way, without having to think about what
    low-level transformations might be helpful to get around simplistic
    code generators. We are well past the primitive code generators of
    the 1950s.


    --- 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 Aug 19 21:55:56 2026
    On Tue, 18 Aug 2026 15:42:54 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:


    That isn't surprising, considering that the recursive call
    is not tail recursive.


    As mentioned above, the presented pseudo-code serves for illustration.
    The actual code executed the same multiplications in the same order but
    was writen in iterative style.



    --- 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 Aug 19 18:25:36 2026
    Michael S <already5chosen@yahoo.com> writes:

    On Tue, 18 Aug 2026 15:42:54 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    That isn't surprising, considering that the recursive call
    is not tail recursive.

    As mentioned above, the presented pseudo-code serves for illustration.
    The actual code executed the same multiplications in the same order but
    was writen in iterative style.

    Right. Even though transformed into an iterative function body, the
    pseudocode being a non-tail-recursive formulation might induce a bad
    result in the resulting iterative code. General recursion can easily
    produce bad structure relative to a more linear method.

    It might be interesting to see the iterative code that you actually
    ran, assuming of course there isn't too much clutter from how the multiplications were done, etc.

    --- 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 Aug 20 22:03:49 2026
    On Wed, 19 Aug 2026 18:25:36 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Tue, 18 Aug 2026 15:42:54 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    That isn't surprising, considering that the recursive call
    is not tail recursive.

    As mentioned above, the presented pseudo-code serves for
    illustration. The actual code executed the same multiplications in
    the same order but was writen in iterative style.

    Right. Even though transformed into an iterative function body, the pseudocode being a non-tail-recursive formulation might induce a bad
    result in the resulting iterative code. General recursion can easily
    produce bad structure relative to a more linear method.

    It might be interesting to see the iterative code that you actually
    ran, assuming of course there isn't too much clutter from how the multiplications were done, etc.

    It was 8 years ago.
    I didn't preserve intermediate variants that did not make it into final solution.


    --- 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 Fri Aug 21 07:31:16 2026
    Michael S <already5chosen@yahoo.com> writes:

    On Wed, 19 Aug 2026 18:25:36 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    Michael S <already5chosen@yahoo.com> writes:

    On Tue, 18 Aug 2026 15:42:54 -0700
    Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:

    That isn't surprising, considering that the recursive call
    is not tail recursive.

    As mentioned above, the presented pseudo-code serves for
    illustration. The actual code executed the same multiplications in
    the same order but was writen in iterative style.

    Right. Even though transformed into an iterative function body, the
    pseudocode being a non-tail-recursive formulation might induce a bad
    result in the resulting iterative code. General recursion can easily
    produce bad structure relative to a more linear method.

    It might be interesting to see the iterative code that you actually
    ran, assuming of course there isn't too much clutter from how the
    multiplications were done, etc.

    It was 8 years ago.
    I didn't preserve intermediate variants that did not make it into
    final solution.

    Oh, too bad. Thank you for letting me know.

    --- 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 Aug 21 17:22:30 2026
    On 8/18/2026 4:32 AM, David Brown wrote:
    ...
    You should also drop the C90 "declare all variables at the top of the function" style.ÿ It's a bad idea in C, and a terrible idea in C++.ÿ You don't want to be unnecessarily creating a std::string object and running
    its constructor and destructor in a function that should be fast.
    Instead, put the declaration where it is needed :

    ÿÿÿÿconst std::string str = "ERROR ..."

    Real programmers can write Fortran code in any language.

    Lynn




    --- 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 Sat Aug 22 12:30:42 2026
    On 22/08/2026 00:22, Lynn McGuire wrote:
    On 8/18/2026 4:32 AM, David Brown wrote:
    ...
    You should also drop the C90 "declare all variables at the top of the
    function" style.ÿ It's a bad idea in C, and a terrible idea in C++.
    You don't want to be unnecessarily creating a std::string object and
    running its constructor and destructor in a function that should be
    fast. Instead, put the declaration where it is needed :

    ÿÿÿÿÿconst std::string str = "ERROR ..."

    Real programmers can write Fortran code in any language.


    That may be true - but the real question is, should they?


    --- 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 Sun Aug 23 06:50:55 2026
    scott@slp53.sl.home (Scott Lurndal) writes:

    [on using -1 to produce all ones in an unsigned type]

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    A problem with patterns like ~0ul is that they are type specific.
    If the type of the destination changes, a wrong value might be the
    result. Also constructs using a suffix on an integer constant are
    limited in which types they can accommodate. Recently I have found
    it useful to employ 128-bit types, including __uint128_t, which
    cannot be designated using a suffix. Using cast is even worse. By
    contrast using -1 always works, regardless of the target type, and
    even for types outside of the standard basic types. If someone
    feels the use of -1 needs explaining, that is easily done with a
    comment:

    some_unsigned_type foo = -1; // all ones

    Personally I think every serious C developer should be thoroughly
    familiar with the use of -1 in conjunction with unsigned types, and
    not even need the comment. But I recognize that some circumstances
    may benefit from an explicit gloss.

    --- 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 Sun Aug 23 09:14:10 2026
    Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    I'd use ~0ul to get all-ones, -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    The idea that all ones and the largest value should be treated
    differently seems rather odd. Surely it is immediately obvious
    that the largest value (of any unsigned type) will have all bits
    set to one; using -1 will always provide both.

    The fact that they happen to be the same value is a technical detail
    that I don't necessarily want to worry about. Whether I use ~0ul
    or -1 depends on which concept I want to express.

    This idea seems even odder. Presumably the point of expressing a
    concept is to convey it to the reader. I think very few readers
    would understand what distinction is intended by the different
    writings here. A simpler and more reliable way is just to use a
    comment

    size_t k = -1; // largest value
    size_t mask = -1; // all ones

    --- 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 Mon Aug 24 19:09:00 2026
    On 8/22/2026 5:30 AM, David Brown wrote:
    On 22/08/2026 00:22, Lynn McGuire wrote:
    On 8/18/2026 4:32 AM, David Brown wrote:
    ...
    You should also drop the C90 "declare all variables at the top of the
    function" style.ÿ It's a bad idea in C, and a terrible idea in C++.
    You don't want to be unnecessarily creating a std::string object and
    running its constructor and destructor in a function that should be
    fast. Instead, put the declaration where it is needed :

    ÿÿÿÿÿconst std::string str = "ERROR ..."

    Real programmers can write Fortran code in any language.


    That may be true - but the real question is, should they?

    Sure.

    Lynn


    --- 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 Aug 26 02:27:45 2026
    On 2026-08-18 01:49, Keith Thompson wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most obvious,
    most consistent, and thus to be expected to be understood by most if
    not all C-programmers. But do we need the type qualification at all?
    A quick test seems to indicate that '~0' can be used for all integral
    types. (That's what my compiler says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    Isn't SIZE_MAX supposed to cover that for size_t at least? Are there
    other unsigned types that lack such a constant? (I haven't checked.)


    The fact that they happen to be the same value is a technical detail
    that I don't necessarily want to worry about. Whether I use ~0ul
    or -1 depends on which concept I want to express.

    IMO bit-ops for bits, and predefined constants (if available) for the
    maxima of amount types. The '-1' I consider a typical C-kluge; in "C"
    I'm used to it so I've no problems if I see that or to use it in cases
    I'm not too much concerned about, um.., call it "symbolic exactness".

    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 Wed Aug 26 02:48:59 2026
    On 2026-08-17 20:37, David Brown wrote:
    [ [tail] recursion optimisation of ipow()ÿ]

    As I noted earlier, it will make very little difference in this case
    because the recursion depth is not going to me more than a couple of
    levels anyway.

    BTW, out of curiosity I compiled the iterative version that I've shown upthread[*] with different optimization levels.

    Given that the code primitives are, well, primitive and easily mapable
    I didn't expect much but - with a bit of additional code-frame to not constantly feed the same values for 'a' and 'b' - I recall to have had
    got a comparably huge performance gain (2.65 vs. 3.65) for an optimized
    ipow() function.

    Janis

    [*] which had been

    long int ipow (long int a, unsigned int n)
    {
    long int res = 1;
    for ( ; n > 0; n /= 2) {
    if (n & 1)
    res *= a;
    a *= a;
    }
    return res;
    }


    --- 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 Aug 25 17:56:55 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-18 01:49, Keith Thompson wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.
    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most obvious,
    most consistent, and thus to be expected to be understood by most if
    not all C-programmers. But do we need the type qualification at all?
    A quick test seems to indicate that '~0' can be used for all integral
    types. (That's what my compiler says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int. Converting it to an unsigned type
    always yields the largest value of that type. Same for -1 of any signed
    type.

    -1u is of type unsigned int. Converting it to an unsigned type wider
    than unsigned int will not give you the largest value of that type.
    Using -1u makes sense only if you know you want a value of type unsigned
    int.

    #include <stdio.h>
    int main(void) {
    unsigned long long a = -1;
    unsigned long long b = -1u;
    printf("%llu\n%llu\n", a, b);
    }

    18446744073709551615
    4294967295

    (Results may vary.)

    Isn't SIZE_MAX supposed to cover that for size_t at least? Are there
    other unsigned types that lack such a constant? (I haven't checked.)

    I don't know of any unsigned types defined in the standard library that
    don't have *_MAX macros (I also haven't checked). User-defined unsigned
    types likely won't have *_MAX macros. SIZE_MAX didn't exist in C90
    (probably not a concern these days).

    [...]

    --
    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 Wed Aug 26 03:56:00 2026
    On 2026-08-26 02:56, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-18 01:49, Keith Thompson wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    Some people see that as an advantage - being able to write "unsigned >>>>> very_big = -1;". I dislike it personally, but styles and preferences >>>>> vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.
    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most obvious,
    most consistent, and thus to be expected to be understood by most if
    not all C-programmers. But do we need the type qualification at all?
    A quick test seems to indicate that '~0' can be used for all integral
    types. (That's what my compiler says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int. Converting it to an unsigned type
    always yields the largest value of that type. Same for -1 of any signed type.

    -1u is of type unsigned int. Converting it to an unsigned type wider
    than unsigned int will not give you the largest value of that type.
    Using -1u makes sense only if you know you want a value of type unsigned
    int.

    I'm not sure it was clear that my "But do we need the type qualification
    at all?" remark was meant for the '~0' context and "all-bits-set case".

    Mind, you had previously written: "I prefer using ~0ul". - And I was
    asking whether that would be necessary here, i.e. for the bits-case and
    unknown sizes of the underlying types. - I'd think that a "generic" '~0'
    would suffice (and impose the least surprises).

    (To set _subsets_ of bits to all '1' is a different question.)

    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 Tue Aug 25 19:57:07 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write
    "unsigned very_big = -1;". I dislike it personally, but styles
    and preferences vary, and it has portability advantages over,
    say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood
    by most if not all C-programmers. But do we need the type
    qualification at all? A quick test seems to indicate that '~0'
    can be used for all integral types. (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int. Converting it to an unsigned type
    always yields the largest value of that type. Same for -1 of any
    signed type.

    -1u is of type unsigned int. Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that
    type. Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and "all-bits-set case".

    Mind, you had previously written: "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    The expression -1 works for all conforming implementations.

    Generally I tend to prefer code that always works over code
    that only sometimes works.

    --- 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 Aug 26 05:33:38 2026
    On 2026-08-26 04:57, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write
    "unsigned very_big = -1;". I dislike it personally, but styles
    and preferences vary, and it has portability advantages over,
    say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood
    by most if not all C-programmers. But do we need the type
    qualification at all? A quick test seems to indicate that '~0'
    can be used for all integral types. (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int. Converting it to an unsigned type
    always yields the largest value of that type. Same for -1 of any
    signed type.

    -1u is of type unsigned int. Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that
    type. Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and
    "all-bits-set case".

    Mind, you had previously written: "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    Not sure I understand your formulation ("some conforming ...").

    Are you implying that the following examples are non-portable,
    undefined, or depending on the concrete (standard-)conforming
    implementation, or something else?

    short unsigned int sd = ~0;
    unsigned int d = ~0;
    long unsigned int ld = ~0;
    long long unsigned int lld = ~0;

    The comment in my K&R copy sounds as if it should work on any
    integral type like that. - Have the C-standards changed that?

    Can you provide some evidence or C-standard-quote where that is
    documented? - I'm really interested to know.

    Janis


    [...]
    Generally I tend to prefer code that always works over code
    that only sometimes works.

    I'd say that most people would agree to that triviality.

    I think we can spare us such Kindergarten-rhetorics; it neither
    supports or affirmates the answer nor provides any evidence for
    the expressed statement. - Thanks.


    --- 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 Aug 25 22:52:33 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 04:57, Tim Rentsch wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write
    "unsigned very_big = -1;". I dislike it personally, but styles >>>>>>>> and preferences vary, and it has portability advantages over,
    say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood
    by most if not all C-programmers. But do we need the type
    qualification at all? A quick test seems to indicate that '~0'
    can be used for all integral types. (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int. Converting it to an unsigned type
    always yields the largest value of that type. Same for -1 of any
    signed type.

    -1u is of type unsigned int. Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that
    type. Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and
    "all-bits-set case".

    Mind, you had previously written: "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    Not sure I understand your formulation ("some conforming ...").

    Are you implying that the following examples are non-portable,
    undefined, or depending on the concrete (standard-)conforming
    implementation, or something else?

    Yes.

    short unsigned int sd = ~0;
    unsigned int d = ~0;
    long unsigned int ld = ~0;
    long long unsigned int lld = ~0;

    The comment in my K&R copy sounds as if it should work on any
    integral type like that. - Have the C-standards changed that?

    If you mean the original K&R then yes.

    Can you provide some evidence or C-standard-quote where that is
    documented? - I'm really interested to know.

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

    Section 6.2.6, Representation of types, subsection 6.2.6.2,
    Integer types. Give particular attention to paragraphs 2
    through 4.

    Also section 6.5 paragraph 4. I'm sorry I'm not able to quote
    these passages here; some temporary difficulties are preventing
    my doing that.


    [...]
    Generally I tend to prefer code that always works over code
    that only sometimes works.

    I'd say that most people would agree to that triviality.

    I think we can spare us such Kindergarten-rhetorics; it neither
    supports or affirmates the answer nor provides any evidence for
    the expressed statement. - Thanks.

    First my comment wasn't meant to be directed at you. I was
    just stating a general principle.

    Second I could agree that such statements should go without
    saying, except that all too often there are examples given that
    seem to violate them. Using ~0u or ~0ul are a case in point:
    both of these forms are fragile. Yet such constructs or other
    fragile patterns are frequently presented as conventional
    wisdom.

    Third for supporting statements I have given references above.
    You should be able to find all the explanation needed in the
    referenced passages.

    Let me say again that nothing in these last two replies was
    meant to be antagonistic. My aim has been simply to provide
    factual answers, along with a general statement meant to explain
    why one might want to prefer -1 over some of the suggested
    alternatives.

    --- 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 Aug 26 09:48:41 2026
    On 26/08/2026 05:33, Janis Papanagnou wrote:
    On 2026-08-26 04:57, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write
    "unsigned very_big = -1;".ÿ I dislike it personally, but styles >>>>>>>> and preferences vary, and it has portability advantages over,
    say, 0xffff'ffff.

    I also dislike that use of -1.ÿ I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly.ÿ As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood
    by most if not all C-programmers.ÿ But do we need the type
    qualification at all?ÿ A quick test seems to indicate that '~0'
    can be used for all integral types.ÿ (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int.ÿ Converting it to an unsigned type
    always yields the largest value of that type.ÿ Same for -1 of any
    signed type.

    -1u is of type unsigned int.ÿ Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that
    type.ÿ Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and
    "all-bits-set case".

    Mind, you had previously written:ÿ "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    Not sure I understand your formulation ("some conforming ...").

    Are you implying that the following examples are non-portable,
    undefined, or depending on the concrete (standard-)conforming
    implementation, or something else?

    short unsigned int sd = ~0;
    unsigned int d = ~0;
    long unsigned int ld = ~0;
    long long unsigned int lld = ~0;

    The behaviours of these are all defined, but are at least partially implementation-defined.

    "0" is of type "int". So "~0" gives the "int" value where all bits are
    set to 1. Given two's complement representation (since we are now on
    C23), that means the initialisations are the same as if you had written
    "= -1;", and in each case your variable gets the highest value of the
    target unsigned integer type.

    Prior to C23, two's complement was not the only representation
    available. The bit-inversion of 0 is not necessarily the value 1. With sign-magnitude, it would (I think) be INT_MIN, and the conversion to an unsigned type would not be all ones.

    (Padding bits, if any, should not affect the results here.)



    --- 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 Aug 26 03:29:39 2026
    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    [...]
    The expression ~0 works for some conforming implementations.

    The expression -1 works for all conforming implementations.

    Generally I tend to prefer code that always works over code
    that only sometimes works.

    Are you referring to implementations that don't use 2's-complement?
    Such implementations are non-conforming as of the current C standard
    (C23).

    --
    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 Scott Lurndal@3:633/10 to All on Wed Aug 26 15:40:00 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    On 2026-08-18 01:49, Keith Thompson wrote:
    scott@slp53.sl.home (Scott Lurndal) writes:
    David Brown <david.brown@hesbynett.no> writes:
    [...]
    Some people see that as an advantage - being able to write "unsigned
    very_big = -1;". I dislike it personally, but styles and preferences
    vary, and it has portability advantages over, say, 0xffff'ffff.

    I also dislike that use of -1. I prefer using ~0ul to get all-ones.

    I'd use ~0ul to get all-ones,

    Exactly. As '~' is the bit-complement operator it's the most obvious,
    most consistent, and thus to be expected to be understood by most if
    not all C-programmers. But do we need the type qualification at all?
    A quick test seems to indicate that '~0' can be used for all integral
    types. (That's what my compiler says, don't know about the standard.)

    I consider it as a note to the reader, not to the compiler.


    --- 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 Aug 26 20:29:32 2026
    On 2026-08-26 09:48, David Brown wrote:
    On 26/08/2026 05:33, Janis Papanagnou wrote:
    On 2026-08-26 04:57, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write
    "unsigned very_big = -1;".ÿ I dislike it personally, but styles >>>>>>>>> and preferences vary, and it has portability advantages over, >>>>>>>>> say, 0xffff'ffff.

    I also dislike that use of -1.ÿ I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly.ÿ As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood >>>>>> by most if not all C-programmers.ÿ But do we need the type
    qualification at all?ÿ A quick test seems to indicate that '~0'
    can be used for all integral types.ÿ (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not
    obvious *which* unsigned type I'm using).

    -1 is an expression of type int.ÿ Converting it to an unsigned type
    always yields the largest value of that type.ÿ Same for -1 of any
    signed type.

    -1u is of type unsigned int.ÿ Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that
    type.ÿ Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and
    "all-bits-set case".

    Mind, you had previously written:ÿ "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    Not sure I understand your formulation ("some conforming ...").

    Are you implying that the following examples are non-portable,
    undefined, or depending on the concrete (standard-)conforming
    implementation, or something else?

    short unsigned int sd = ~0;
    unsigned int d = ~0;
    long unsigned int ld = ~0;
    long long unsigned int lld = ~0;

    The behaviours of these are all defined, but are at least partially implementation-defined.

    ("defined", "partially", "implementation-defined", well... - what
    can a C-user *reliably* deduce from that...)


    "0" is of type "int".ÿ So "~0" gives the "int" value where all bits are
    set to 1.ÿ Given two's complement representation (since we are now on
    C23), that means the initialisations are the same as if you had written
    "= -1;", and in each case your variable gets the highest value of the
    target unsigned integer type.

    Prior to C23, two's complement was not the only representation
    available.ÿ The bit-inversion of 0 is not necessarily the value 1.ÿ With sign-magnitude, it would (I think) be INT_MIN, and the conversion to an unsigned type would not be all ones.

    (Padding bits, if any, should not affect the results here.)

    I had written a longish reply on that but abstain from sending it,
    instead, for the moment, I just like to ask - to obtain a better
    understanding! - which of the following declarations are reliable
    or unreliable, portable, depending on specific compilers - you know
    what I mean - in your understanding.

    All of the following declarations produce (with my GNU C-compiler)
    no error diagnostics and no warning, not even with -Wall -Wpedantic
    and with various standards from c89 to c2x defined). And they all
    (i.e. the below printed subset) produce the same result (-1).


    #include <stdio.h>

    unsigned long int ula0 = 0;
    unsigned long int ula1 = 0UL;
    unsigned long int ula2 = (unsigned long int) (0);

    unsigned long int ulb0 = -1;
    unsigned long int ulb1 = -1UL;
    unsigned long int ulb2 = -(1UL);
    unsigned long int ulb3 = (unsigned long int) (-1);

    unsigned long int ulc0 = ~0;
    unsigned long int ulc1 = ~0UL;
    unsigned long int ulc2 = (~0UL);
    unsigned long int ulc3 = (unsigned long int) (~0);

    unsigned long int ulb4 = (short) (-1);
    unsigned long int ulc4 = ~(short) 0;

    int main (void)
    {
    printf ("%ld\t%ld\n", ulb4, ulc4);

    printf ("%ld\t%ld\n", ulb3, ulc3);
    printf ("%ld\t%ld\n", ulb2, ulc2);
    printf ("%ld\t%ld\n", ulb1, ulc1);
    printf ("%ld\t%ld\n", ulb0, ulc0);

    return 0;
    }

    And the following comparisons produce also 1 (true) and no warnings
    when compiling.

    printf ("%d\n", -1L == -1);
    printf ("%d\n", ~0L == ~0);


    Without extending on details of my withheld post, the operation of
    the '~' is in K&R speaking about the "integral types" not the 'int'
    type, as opposed to other operators' context where specifically the
    'int' type is addressed.

    IOW, yet (and still) I have to observe any reliability issue with ~0.

    (Historically I worked also with other C-compilers, mostly commercial
    ones; I never had any issues with that in "C". A lot of other commonly
    known issues of "C" (pointers and memory, for example), but certainly
    not with the bit-ops or type-unqualified literals in that context.)

    Janis


    --- 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 Aug 27 10:12:04 2026
    On 26/08/2026 20:29, Janis Papanagnou wrote:
    On 2026-08-26 09:48, David Brown wrote:
    On 26/08/2026 05:33, Janis Papanagnou wrote:
    On 2026-08-26 04:57, Tim Rentsch wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-26 02:56, Keith Thompson wrote:

    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

    On 2026-08-18 01:49, Keith Thompson wrote:

    scott@slp53.sl.home (Scott Lurndal) writes:

    David Brown <david.brown@hesbynett.no> writes:

    [...]

    Some people see that as an advantage - being able to write >>>>>>>>>> "unsigned very_big = -1;".ÿ I dislike it personally, but styles >>>>>>>>>> and preferences vary, and it has portability advantages over, >>>>>>>>>> say, 0xffff'ffff.

    I also dislike that use of -1.ÿ I prefer using ~0ul to get
    all-ones.

    I'd use ~0ul to get all-ones,

    Exactly.ÿ As '~' is the bit-complement operator it's the most
    obvious, most consistent, and thus to be expected to be understood >>>>>>> by most if not all C-programmers.ÿ But do we need the type
    qualification at all?ÿ A quick test seems to indicate that '~0'
    can be used for all integral types.ÿ (That's what my compiler
    says, don't know about the standard.)

    -1 or -1u to get the largest value
    of the type (or preferably UINT_MAX, but -1 is good if it's not >>>>>>>> obvious *which* unsigned type I'm using).

    -1 is an expression of type int.ÿ Converting it to an unsigned type >>>>>> always yields the largest value of that type.ÿ Same for -1 of any
    signed type.

    -1u is of type unsigned int.ÿ Converting it to an unsigned type
    wider than unsigned int will not give you the largest value of that >>>>>> type.ÿ Using -1u makes sense only if you know you want a value of
    type unsigned int.

    I'm not sure it was clear that my "But do we need the type
    qualification at all?" remark was meant for the '~0' context and
    "all-bits-set case".

    Mind, you had previously written:ÿ "I prefer using ~0ul". - And I
    was asking whether that would be necessary here, i.e. for the
    bits-case and unknown sizes of the underlying types. - I'd think
    that a "generic" '~0' would suffice (and impose the least
    surprises).

    The expression ~0 works for some conforming implementations.

    Not sure I understand your formulation ("some conforming ...").

    Are you implying that the following examples are non-portable,
    undefined, or depending on the concrete (standard-)conforming
    implementation, or something else?

    short unsigned int sd = ~0;
    unsigned int d = ~0;
    long unsigned int ld = ~0;
    long long unsigned int lld = ~0;

    The behaviours of these are all defined, but are at least partially
    implementation-defined.

    ("defined", "partially", "implementation-defined", well... - what
    can a C-user *reliably* deduce from that...)


    That is what I have tried to explain!


    "0" is of type "int".ÿ So "~0" gives the "int" value where all bits
    are set to 1.ÿ Given two's complement representation (since we are now
    on C23), that means the initialisations are the same as if you had
    written "= -1;", and in each case your variable gets the highest value
    of the target unsigned integer type.

    Prior to C23, two's complement was not the only representation
    available.ÿ The bit-inversion of 0 is not necessarily the value 1.
    With sign-magnitude, it would (I think) be INT_MIN, and the conversion
    to an unsigned type would not be all ones.

    (Padding bits, if any, should not affect the results here.)

    I had written a longish reply on that but abstain from sending it,
    instead, for the moment, I just like to ask - to obtain a better understanding! - which of the following declarations are reliable
    or unreliable, portable, depending on specific compilers - you know
    what I mean - in your understanding.


    To be clear - assuming that my understanding is correct, ~0 works
    exactly like -1 on all two's complement systems. And all C
    implementations other than a couple of ancient mainframes use two's complement. Until C23, there is therefore a hypothetical
    non-portability with ~0, but no issue in practical reality. From C23
    onwards, even that hypothetical is gone.

    All of the following declarations produce (with my GNU C-compiler)
    no error diagnostics and no warning, not even with -Wall -Wpedantic
    and with various standards from c89 to c2x defined). And they all
    (i.e. the below printed subset) produce the same result (-1).


    Be a little wary of relying too much on testing with a compiler - it can
    be a help for many things, but often fails to give the full picture.
    Testing can only ever show the presence of issues, not their absence.


    Without extending on details of my withheld post, the operation of
    the '~' is in K&R speaking about the "integral types" not the 'int'
    type, as opposed to other operators' context where specifically the
    'int' type is addressed.

    In the C standards, "~" applies to "integer types".


    IOW, yet (and still) I have to observe any reliability issue with ~0.

    And unless you are maintaining code for a Burrough's mainframe, you
    never will.



    --- 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 Aug 27 04:45:29 2026
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    Without extending on details of my withheld post, the operation of
    the '~' is in K&R speaking about the "integral types" not the 'int'
    type, as opposed to other operators' context where specifically the
    'int' type is addressed.

    Do you mean K&R 1 or 2?

    K&R1 consistently says that the operands of the bitwise operators
    (~, <<, >>, &, |, ^) "must be integral". I don't see any operators
    that are restricted to int operands.

    I seem to recall that you use a non-English translation. Can you
    provide specifics?

    [...]

    --
    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 Rosario19@3:633/10 to All on Sat Aug 29 17:14:34 2026
    On Tue, 18 Aug 2026 22:17:40 +0300, Michael S
    <already5chosen@yahoo.com> wrote:


    wword ipow(wword a, wword n)
    {
    if (n < 2)
    return n == 0 ? 1 : a;

    wword y = ipow(a, n/2);
    y *= y;
    if (n & 1)
    y *= a;
    return y;
    }

    Please, treat it as a pseudocode.
    Real code was more complicated, with function calls instead of *
    and recursion was manually converted to iteration.

    The result was slower than the following (pseudo) code:

    wword ipow(wword a, wword n)
    {
    wword y = 1, p = a;
    while (1) {
    if (n & 1)
    y *= p;
    n /= 2;
    if (!n)
    break;
    p *= p;
    }
    return y;
    }

    I didn't try to investiagete reasons for the difference.


    if a b are unsigned I think

    ipow(a,b) if just ltor(a,b, MaxUnsignedInteger)

    where ltor or powermod is one algo I not find in internet but exist


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Rosario19@3:633/10 to All on Sat Aug 29 17:22:31 2026
    On Tue, 11 Aug 2026 16:56:04 +0200, Bonita Montero wrote:

    This is the integer pow() code so far I wrote in C++:

    template<typename Int>
    constexpr optional<Int> ipow( Int b, Int e )
    {
    constexpr bool Sgn = is_signed_v<Int>;
    using uint = make_unsigned_t<Int>;
    if( !b )
    return !e;
    uint ub, ue;
    if constexpr( Sgn )
    if( e >= 0 )
    {
    ub = abs( b );
    ue = abs( e );
    }
    else
    return abs( b ) == 1;
    else
    ub = b, ue = e;
    uint result = 1, msk = 1, sq = ub;
    while( ue )
    {
    if( (ue & msk) )
    {
    uint next = result * sq;
    if( next / sq != result )
    return nullopt;
    result = next;
    ue &= ~msk;
    }
    msk <<= 1;
    if( sq * sq / sq != sq )
    return nullopt;
    sq *= sq;
    }
    if constexpr( Sgn )
    if( bool neg = b < 0; neg && (e & 1) )
    if( result <= (uint)numeric_limits<Int>::min() )
    result = -(Int)result;
    else
    return nullopt;
    return result;

    }

    I didn't test all corner cases, but for values which don't overflow the
    code should be corrent. The crucial case about the performance here is
    that I need a division to check for overflows; in these cases you get
    a nullopt. With fp-values you get inf and that's less expensive.

    float can not handle numbers ipow or ltor or powermod can...
    example ipow(123456,123456) with the right trunched result...


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From boltar@3:633/10 to All on Sat Aug 29 15:43:36 2026
    On Sat, 29 Aug 2026 17:22:31 +0200
    Rosario19 <Ros@invalid.invalid> gabbled:
    On Tue, 11 Aug 2026 16:56:04 +0200, Bonita Montero wrote:

    This is the integer pow() code so far I wrote in C++:

    template<typename Int>
    constexpr optional<Int> ipow( Int b, Int e )
    {
    constexpr bool Sgn = is_signed_v<Int>;
    using uint = make_unsigned_t<Int>;
    if( !b )
    return !e;
    uint ub, ue;
    if constexpr( Sgn )
    if( e >= 0 )
    {
    ub = abs( b );
    ue = abs( e );
    }
    else
    return abs( b ) == 1;
    else
    ub = b, ue = e;
    uint result = 1, msk = 1, sq = ub;
    while( ue )
    {
    if( (ue & msk) )
    {
    uint next = result * sq;
    if( next / sq != result )
    return nullopt;
    result = next;
    ue &= ~msk;
    }
    msk <<= 1;
    if( sq * sq / sq != sq )
    return nullopt;
    sq *= sq;
    }
    if constexpr( Sgn )
    if( bool neg = b < 0; neg && (e & 1) )
    if( result <= (uint)numeric_limits<Int>::min() )
    result = -(Int)result;
    else
    return nullopt;
    return result;

    }

    I didn't test all corner cases, but for values which don't overflow the >>code should be corrent. The crucial case about the performance here is
    that I need a division to check for overflows; in these cases you get
    a nullopt. With fp-values you get inf and that's less expensive.

    float can not handle numbers ipow or ltor or powermod can...
    example ipow(123456,123456) with the right trunched result...

    Also maths functions should never return an optional. They should return the numeric result or NaN.


    --- 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 Sun Aug 30 05:33:31 2026
    Am 29.08.2026 um 17:43 schrieb boltar@caprica.universe:

    Also maths functions should never return an optional. They should return the numeric result or NaN.
    There are no NaNs with integrals, so an optional is o.k..


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From boltar@3:633/10 to All on Sun Aug 30 13:02:01 2026
    On Sun, 30 Aug 2026 05:33:31 +0200
    Bonita Montero <Bonita.Montero@gmail.com> gabbled:
    Am 29.08.2026 um 17:43 schrieb boltar@caprica.universe:

    Also maths functions should never return an optional. They should return the >> numeric result or NaN.
    There are no NaNs with integrals, so an optional is o.k..

    Wtf are you talking about, its raising an integer to a power, integrals don't come into it.


    --- 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 Sun Aug 30 19:53:53 2026
    Am 30.08.2026 um 15:02 schrieb boltar@caprica.universe:

    Wtf are you talking about, its raising an integer to a power, integrals don't come into it.
    An integer pow can easily be out of bounds, that's while I'm
    using an optional to signal that. In my latest version I even
    use a std::expected to signal an overflow and an infinte result.
    That's proper coding.


    --- 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 Aug 31 10:04:06 2026
    On 30/08/2026 15:02, boltar@caprica.universe wrote:
    On Sun, 30 Aug 2026 05:33:31 +0200
    Bonita Montero <Bonita.Montero@gmail.com> gabbled:
    Am 29.08.2026 um 17:43 schrieb boltar@caprica.universe:

    Also maths functions should never return an optional. They should
    return the
    numeric result or NaN.
    There are no NaNs with integrals, so an optional is o.k..

    Wtf are you talking about, its raising an integer to a power, integrals don't
    come into it.


    I assume Bonita was using "integral" as an adjective - an alternative to "integer types" - rather than the term from calculus.

    The discussion was about a function that raises an integer to an
    integer, returning an integer - with various possible choices of the
    concrete integer types to use. Integer types in C and C++ do not have
    NaNs or other error value indicators. So this kind of function cannot
    use such returns to indicate errors.

    Alternatives include :

    1. Let overflow be UB, and don't care what you return on overflow.

    2. Pick a specific integer value to return if there is an overflow.

    3. Call an error-handling function of some sort.

    4. Throw an exception (C++ only, obviously).

    5. Use a side-channel indication, like errno.

    6. Augment the return to include an indication of error or the validity
    of the result. For C++, std::optional<> and std::expected<> are both
    solid choices there.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bart@3:633/10 to All on Mon Aug 31 14:18:58 2026
    On 31/08/2026 09:04, David Brown wrote:
    On 30/08/2026 15:02, boltar@caprica.universe wrote:
    On Sun, 30 Aug 2026 05:33:31 +0200
    Bonita Montero <Bonita.Montero@gmail.com> gabbled:
    Am 29.08.2026 um 17:43 schrieb boltar@caprica.universe:

    Also maths functions should never return an optional. They should
    return the
    numeric result or NaN.
    There are no NaNs with integrals, so an optional is o.k..

    Wtf are you talking about, its raising an integer to a power,
    integrals don't
    come into it.


    I assume Bonita was using "integral" as an adjective - an alternative to "integer types" - rather than the term from calculus.

    The discussion was about a function that raises an integer to an
    integer, returning an integer - with various possible choices of the concrete integer types to use.ÿ Integer types in C and C++ do not have
    NaNs or other error value indicators.ÿ So this kind of function cannot
    use such returns to indicate errors.

    Alternatives include :

    1. Let overflow be UB, and don't care what you return on overflow.

    Yes, I don't see the need for:

    if (ipow(a, 2) + ipow(b, 2) == ipow(c, 2))

    to behave any differently from:

    if (a*a + b*b == c*c)

    2. Pick a specific integer value to return if there is an overflow.

    3. Call an error-handling function of some sort.

    4. Throw an exception (C++ only, obviously).

    5. Use a side-channel indication, like errno.

    6. Augment the return to include an indication of error or the validity
    of the result.ÿ For C++, std::optional<> and std::expected<> are both
    solid choices there.

    How would this even work for an example that looks like the above?

    With NaNs, I believe a NaN result early in a expression will propagate
    through to the result, so can be tested for once, or can itself propagate.

    'ipow' would be used where it is more convenient or appropriate than the alternative, or where the exponent is a variable, or where it imparts
    useful extra information.

    (Obviously, in my example, ipow needs more typing and is less convenient.)




    --- 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 Aug 31 14:48:17 2026
    David Brown <david.brown@hesbynett.no> writes:
    On 30/08/2026 15:02, boltar@caprica.universe wrote:

    The discussion was about a function that raises an integer to an
    integer, returning an integer - with various possible choices of the >concrete integer types to use. Integer types in C and C++ do not have
    NaNs or other error value indicators. So this kind of function cannot
    use such returns to indicate errors.

    Alternatives include :


    4. Throw an exception (C++ only, obviously).

    cf. longjmp.

    --- 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 Aug 31 17:25:49 2026
    On 31/08/2026 15:18, bart wrote:
    On 31/08/2026 09:04, David Brown wrote:
    On 30/08/2026 15:02, boltar@caprica.universe wrote:
    On Sun, 30 Aug 2026 05:33:31 +0200
    Bonita Montero <Bonita.Montero@gmail.com> gabbled:
    Am 29.08.2026 um 17:43 schrieb boltar@caprica.universe:

    Also maths functions should never return an optional. They should
    return the
    numeric result or NaN.
    There are no NaNs with integrals, so an optional is o.k..

    Wtf are you talking about, its raising an integer to a power,
    integrals don't
    come into it.


    I assume Bonita was using "integral" as an adjective - an alternative
    to "integer types" - rather than the term from calculus.

    The discussion was about a function that raises an integer to an
    integer, returning an integer - with various possible choices of the
    concrete integer types to use.ÿ Integer types in C and C++ do not have
    NaNs or other error value indicators.ÿ So this kind of function cannot
    use such returns to indicate errors.

    Alternatives include :

    1. Let overflow be UB, and don't care what you return on overflow.

    Yes, I don't see the need for:

    ÿÿ if (ipow(a, 2) + ipow(b, 2) == ipow(c, 2))

    to behave any differently from:

    ÿÿ if (a*a + b*b == c*c)

    Agreed.


    2. Pick a specific integer value to return if there is an overflow.

    3. Call an error-handling function of some sort.

    4. Throw an exception (C++ only, obviously).

    5. Use a side-channel indication, like errno.

    6. Augment the return to include an indication of error or the
    validity of the result.ÿ For C++, std::optional<> and std::expected<>
    are both solid choices there.

    How would this even work for an example that looks like the above?

    A C++ std::optional<int> is approximately like a struct with an int, and
    a bool to indicate validity, along with some convenient operations and conversions.


    With NaNs, I believe a NaN result early in a expression will propagate through to the result, so can be tested for once, or can itself propagate.


    With std::optional<int>, you would still need to do some testing of the results to see if you had a successful "int" or not. But the result
    type carries this information along with non-overflow result, and is relatively neat to test.

    It is possible in C++ to do better. Perhaps a good choice would be a
    template "checked<>" so that a "checked<int>" carries a bool "NaN" flag
    along with a non-NaN value. Then common integer operations could be overloaded to support this in a similar manner to a non-signalling NaN
    in floating point. (It would also be possible to use INT_MAX to
    indicate NaN, keeping the type more compact.)

    'ipow' would be used where it is more convenient or appropriate than the alternative, or where the exponent is a variable, or where it imparts
    useful extra information.

    (Obviously, in my example, ipow needs more typing and is less convenient.)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)