Casting to int in awk

Most new awks have an int() function. But the method for casting documented in ‘The Awk Programming Language’ is shown as you do it, by using numericValue and +0. I don’t have the book handy, but I think you can also cast for float value by using +0.0. I hope this helps.

Enum and performance

Casting from int to an enum is extremely cheap… it’ll be faster than a dictionary lookup. Basically it’s a no-op, just copying the bits into a location with a different notional type. Parsing a string into an enum value will be somewhat slower. I doubt that this is going to be a bottleneck for you … Read more

Java correct way convert/cast object to Double

new Double(object.toString()); But it seems weird to me that you’re going from an Object to a Double. You should have a better idea what class of object you’re starting with before attempting a conversion. You might have a bit of a code quality problem there. Note that this is a conversion, not casting.

Casting an object to a generic interface

If I understand the question, then the most common approach would be to declare a non-generic base-interface, i.e. internal interface IRelativeTo { object getRelativeTo(); // or maybe something else non-generic void setRelativeTo(object relativeTo); } internal interface IRelativeTo<T> : IRelativeTo where T : IObject { new T getRelativeTo(); new void setRelativeTo(T relativeTo); } Another option is … Read more