I will take tonight to rant about Visual Studio 2022. But I'll start with what Monte Cook would call a "rave": in 2017ish, Microsoft updated C# to "version 7".
This added the Cbrt() to the System.Math statics. No more imprecise Math.Pow(x, 1.0/3.0), between Sqrt and Sqrt(Sqrt). Our boys in Redmond brought in centuries of work for a cube-dedicated algorithm. It would run faster and read easier; with the bonus that it supports cubing a negative number, which .Pow preempted. The only cost, being some extra code in the 'base.
I want my older code to use this. The issues here: csproj .NET 4 Properties throws up a brickwall at 4.8; 4.8 doesn't get the new C#. Not unanticipated; bro just upgraaaaaACK.
The best means I could find was to make a new Class Library, or Winforms whatever; then shift all the classes over there, for recompile. This creator, rightclicking from the .sln, has two options. The first is the Class Library; the second "Class Library (.NET Framework)". You don't know which is which until you choose it; the latter is brickwalled to 4.8. Only the former gives you options for later .NETs.
I spent rather more time than I wanted on shuffling all of this around. But now finally: I get real cube roots.
UPDATE 5/25 You know what we get in C# 8? We get generics "where T : notnull". And .NET 7's system.numerics offers INumber.
No comments:
Post a Comment