Closed
Description
Unless I'm mistaken there's no way to pass an infinity through to C# from Python?
namespace Demo {
public static class TestDoubleCast {
public static double PassThru(double arg) {
return arg;
}
}
}
In [3]: from Demo import TestDoubleCast
In [4]: TestDoubleCast.PassThru(1)
Out[4]: 1.0
In [5]: TestDoubleCast.PassThru(3.14159)
Out[5]: 3.14159
In [6]: TestDoubleCast.PassThru(inf)
Traceback (most recent call last):
File "<ipython-input-6-b27dffdb9fe9>", line 1, in <module>
TestDoubleCast.PassThru(inf)
TypeError: No method matches given arguments
In [7]: TestDoubleCast.PassThru(System.Double.PositiveInfinity)
Traceback (most recent call last):
File "<ipython-input-9-9828c102a734>", line 1, in <module>
TestDoubleCast.PassThru(System.Double.PositiveInfinity)
TypeError: No method matches given argument
In [10]: System.Double(3.14159) # works as expected
Out[10]: <System.Double at 0xaf31828>
In [11]: System.Double(inf) # would like it to return a System.Double
Traceback (most recent call last):
File "<ipython-input-11-1a15035c8521>", line 1, in <module>
System.Double(inf)
OverflowError: value too large to convert
It would be very useful if the casting machinery could special case infinities so that you could create them from Python and they could be passed as arguments to methods expecting a System.Double
Metadata
Metadata
Assignees
Labels
No labels