int32orfloat

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

changes type to integer float is an integer

Description

this function can be used to distinguish for nofrd wether the argument is a desired point number or a desired resolution of an object.
if (mod(a,(1-1e-18))<1e-9); a=int32(a); end; [isinteger(a), isfloat(a)]


See Also: , isintegerbv

Example Illustration

 missing image of int32orfloat(a)

Syntax

a=int32orfloat(a)

Input Parameter

a: float

Output Parameter

a: same number as float or as integer

Examples


a= int32orfloat (pi), [isinteger(a), isfloat(a)]
a= int32orfloat (2), [isinteger(a), isfloat(a)]




Copyright 2015-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

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.

Input Parameters

Output Results

Algorithm Explanation

The function operates as follows:

  1. It checks if the input number a is very close to an integer. This is done using the modulus operation: mod(a, (1-1e-18)).
  2. If the result of the modulus operation is less than 1e-9, it implies that a is very close to an integer value.
  3. If the condition is satisfied, the function converts a to an integer using int32(a).
  4. If the condition is not satisfied, a remains a floating-point number.

Example Usage

Here are two examples of how the function can be used:

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)

Last html export of this page out of FM database by TL: 2025-09-21