joehodge3rd
(Joe Hodge, III)
1
I would like to recommend a lesson learned in Modula-2. The means of casting types is usually hardware dependent so it and all the data size dependent types should be isolated to a "System" Module for ease of porting. The method of casting using intVariable := (int)insignedIntVariable was replaced in Modula-2 when it became apparent that there was no simple way to search for instances of casting. The solution was to use a function from the System Module to perform the cast as in intVariable := Cast(unsighnedIntVariable). Now one need only search for the name "Cast" to find every instance easily.
Avi
2
Swift doesn't have casting of this type. You "cast" between numeric types by invoking constructors.
Nevin
3
Swift already has a dedicated function for casting between integer types. It is called numericCast().
1 Like
Avi
4
I didn't know about that function. Learn something new...