Class Box2DConvert
The argument conversions of pybox2d's SWIG layer: a Python float passed where C++ takes a float32 rounds
to the nearest float32, and values beyond its range are refused rather than becoming infinities.
public static class Box2DConvert
- Inheritance
-
Box2DConvert
- Inherited Members
Remarks
SWIG's SWIG_AsVal_float refuses x < -FLT_MAX || x > FLT_MAX (so the infinities) and lets NaN
through, which then propagates as NaN.
Methods
FitsFloat32(double)
Whether a Python float converts to float32 without SWIG's overflow refusal (NaN does).
public static bool FitsFloat32(double value)
Parameters
valuedoubleThe value.
Returns
- bool
False for values beyond ±FLT_MAX, the infinities included.
FormatG(double)
Formats a float as C's and Python's %g: 6 significant digits, trailing zeros dropped, exponent as e+XX.
public static string FormatG(double value)
Parameters
valuedoubleThe value.
Returns
- string
The text.
ToFloat32(double, string, int)
Converts a Python float to float32 as SWIG does for a float32 parameter.
public static float ToFloat32(double value, string method, int argument)
Parameters
valuedoubleThe value.
methodstringThe SWIG wrapper name the error names (
b2Vec2___mul__).argumentintThe 1-based argument position the error names.
Returns
- float
The nearest float32.
Exceptions
- OverflowError
Thrown, as Python's
OverflowError, for a value beyond the float32 range, with SWIG's messagein method '…', argument N of type 'float32'.