by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.7, Creation date: 2015-10-04, Last change: 2025-09-14
a=int32orfloat(a)
a: | float |
a: | same number as float or as integer |
a= int32orfloat (pi), [isinteger(a), isfloat(a)]
a= int32orfloat (2), [isinteger(a), isfloat(a)]
This function, named int32orfloat, is designed to determine whether a given floating-point number should be treated as an integer or remain a float. It is part of the SolidGeometry library and was introduced in version 2.7.
The function operates as follows:
a is very close to an integer. This is done using the modulus operation: mod(a, (1-1e-18)).1e-9, it implies that a is very close to an integer value.a to an integer using int32(a).a remains a floating-point number.Here are two examples of how the function can be used:
a = int32orfloat(pi) - This will keep a as a float because pi is not close to an integer.a = int32orfloat(2) - This will convert a to an integer because 2 is exactly an integer.The function is useful for distinguishing whether a number should be treated as a point number or a resolution of an object, based on its proximity to an integer value.
Algorithm explaination created using ChatGPT on 2025-08-18 23:10. (Please note: No guarantee for the correctness of this explanation)