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.
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.
https://wxwidgets.org/ is close but I have yet to try it out.
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
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?
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?
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!
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
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.
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!
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!
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do some of
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.
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.
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?
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?
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!
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?
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do some of them look fractal?
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.
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...
On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:Ahhhh! So, you are not making any animations of the processes. Okay. But
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do some
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.
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.
On 8/14/2026 1:48 PM, Lynn McGuire wrote:
On 8/14/2026 2:08 PM, Chris M. Thomasson wrote:Ahhhh! So, you are not making any animations of the processes. Okay. But
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do some
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.
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.
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
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:Ahhhh! So, you are not making any animations of the processes. Okay.
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do
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.
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.
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.
Deal with it, you fucking cuck!
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:Ahhhh! So, you are not making any animations of the processes. Okay.
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do
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.
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.
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?
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:Ahhhh! So, you are not making any animations of the processes. Okay.
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do
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.
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.
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
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:Ahhhh! So, you are not making any animations of the processes. Okay.
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do
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.
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.
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
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.
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.
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 would rather see a standard user interface toolkit for C++ first.
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.
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:Ahhhh! So, you are not making any animations of the processes. Okay. >>>>> But you have the data to do so...
On 8/13/2026 10:58 PM, Lynn McGuire wrote:
On 8/13/2026 8:51 PM, Chris M. Thomasson wrote:Let me clarify... Do you make renders of a simulation? If so, do >>>>>>> some of them look fractal?
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.
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.
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 ofSorry, I lost you in the first part of your reply. If you are saying
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.
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?.
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?
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.
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.
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.
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
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 */
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 */
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 ..."
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.
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?
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.
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.There are no NaNs with integrals, so an optional is o.k..
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.An integer pow can easily be out of bounds, that's while I'm
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 shouldThere are no NaNs with integrals, so an optional is o.k..
return the
numeric result or NaN.
Wtf are you talking about, its raising an integer to a power, integrals don't
come into it.
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 shouldThere are no NaNs with integrals, so an optional is o.k..
return the
numeric result or NaN.
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.
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).
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 shouldThere are no NaNs with integrals, so an optional is o.k..
return the
numeric result or NaN.
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.)
| Sysop: | Tetrazocine |
|---|---|
| Location: | Melbourne, VIC, Australia |
| Users: | 4 |
| Nodes: | 8 (0 / 8) |
| Uptime: | 76:31:48 |
| Calls: | 221 |
| Files: | 21,513 |
| Messages: | 83,324 |