Conversion from GH_Number to Double

I am trying to convert/cast Object to Double, and get the following message:


How to fix?


In C# it would be:

GH_Number n = GetTheGHNumberSomehow();
double d = (double)n.Value;

I would have guessed, that if the original type is object, you’ll need to cast to GH_Number first, and that you then should be able to directly access the Value without casting.

object a = new GH_Number(17.0);
GH_Number b = (GH_Number) a;
double c = b.Value;

Right, I fell over the float vs float32 naming in F# - I was looking at GH_Number.Value in some F# code of mine, it said float, completely forgetting it is actually double.

Thanks. It works.

2 posts were split to a new topic: Possible to write F# code for Grasshopper?