On 2026-12-01, Bonita Montero <Boni…@gmail.com> wrote:
> Am 01.12.2026 um 18:48 schrieb bartc: >
>> I had the option to use either ° or 'deg': >> >>    15 deg
> > How about that ? > > #include <iostream> > #include <complex> > #include <cmath> > > using namespace std; > > struct degree {}; > > complex<double> operator *( double angle, degree )
complex<double> is too much of a mouthful for a complex type you will be reaching for a lot. How it should have been designed is that there should have been a basic_complex<T> template and complex being a typedef name for basic_complex<double> You know, like string being basic_string<char>. They don't think about ergonomics or consistency at all.
> { > return complex<double>( sin( angle ), cos( angle ) ); > }
This sin(angle), cos(angle) argument list is the best looking thing here --- because it's C? If the C++ people designed it from scratch, it would be some std::math::sin<double>(angle) type fuckery.
> > int main() > { > constexpr double Pi4 = 3.1415926535897932384626433832795 / 4.0;
This is just stupid; a double only holds around 17 decimal digits of precision (15 that are guaranteed to be preserved). Moreover, surely C++ has a pi constant somewhere? Evidently C++20 has ths: #include <iostream> #include <numbers> // ... std::numbers::pi; std::numbers::pi_v<float>; std::numbers::pi_v<long double>; It didn't occur to them until the pandemic hit that numeric programmers might want the language to provide pi. They hit on the idea of avoiding pi_v<double>, like what I'm talking about with the complex<T> verbosity above.
-- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazi…@mstdn.ca