Math Functions: more please! [Kit George]

Math Functions: more please! [Kit George]

  • Comments 7

Jacek Blaszczynski asked this request about some of our Math functionality:

I would greatly appreciate improvements in available set of functions and their behaviour getting them closer to C++ experience. One of misbehaviours is explicit cast of float to int where decimal values got rounded down instead of going rounded up when equal to 0.5(!).

Jacek, we can't change the specific functionality you're asking about since it would break existing consumers. However, keep an eye for new Math.Round functions in Whidbey which should provide the specific functionality you're looking for in this scenario. As for other Math functions, we are planning on adding more over time, it's simply a matter of when, and which ones.

We would love to hear for specific requests from everyone on this issue!

  • "since it would break existing consumers"
    ...or fix a bug they wern't aware of :)
  • Seriously, add single-precision trigonometry methods please!!!!!!!!! :) It seems calling sin\cos et al. and casting the returned double to a single. Results in the double being computed anyway (looking at the generated native assembly, anyway).

    n!
  • The rounding stuff was something that I chased with Kit some time ago. I bugged it during the .NET 2003 beta process, so it's a long standing request from me (and I've raised it again during Whidbey). Kit while being somewhat cryptic in replies has been positive about this.
    It would be nice to have all of the Java.Math.BigDecimal modes.
    IIRC all of the 8087 sin/cos functions are doubles anyway.
  • Somewhat cryptic is my bread and butter ... ;-)
    Seriously though, it's hard to talk about features we haven't shipped yet, and not use a lot of 'maybes'. But you can expect extra rounding support in the near future.

    Thanks for the other suggestions (Single precision Trig/BigNumbers) we'll take those on board!
  • Enhancements I'd like to see in the Math class (since you asked):

    Min and Max each take two parameters. Why only two? Min(params int[] values) and Min(params double[] values) would be extremely useful as well. So would Min(ICollection<int>). And all the other numeric types, like Double, SByte, etc.

    For that matter, how about a generic Min(ICollection<T>) where T : IComparable? It's arguable that it might not belong in Math, since it could compare anything, not just numbers; but wherever it was put, it could be very useful.

    Sum() and Average() methods would also be useful (also taking variable numbers of arguments via params[] and ICollection<>, though these would have to be numeric rather than just IComparable -- unless you had an IAddable<T> interface...)
  • I know it's difficult for you to respond properly to these issues. Its the best response I can hope for given the way most development processes work. My personal response is often:
    "It's on the planned feature list for the next version, but it might not happen"
  • Yup, that's the lingo alright Peter ...

    And Joe, thanks for your suggestions, I've added them to our list for ideas on Math. I love the generic collection integration suggestion, very nice ...
Page 1 of 1 (7 items)