isint32

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

returns true or false if a number has no fraction

Description

In contrast to: isequal((rem(a,1),0)
this function is faster and automatically detects the limit of int32.

Can be used for calculation of number of egdes: if ~isint32(nf); nf=nofrd(R,nf/2); end;

Example Illustration

 missing image of isint32(a)

Syntax

b=isint32(a)

Input Parameter

a: number

Output Parameter

b: true if isequal((rem(a,1),0)




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, isint32, determines if a given number a is an integer without a fractional part, specifically within the limits of an int32 data type.

Input Parameters

Output Results

Algorithm Explanation

The function uses the mod function to determine if the number a has a fractional part. The expression mod(a, (1-1e-18)) calculates the remainder of a when divided by a value slightly less than 1. This is done to account for floating-point precision issues.

The result of mod(a, (1-1e-18)) is then compared to a small threshold value, 1e-9. If the remainder is less than 1e-9, it is considered negligible, and the function returns true, indicating that a is effectively an integer.

This method is faster than using isequal(rem(a,1),0) because it avoids the overhead of the rem function and directly checks for a negligible remainder.

The function is particularly useful in scenarios where the number of edges needs to be calculated, as indicated in the example usage: if ~isint32(nf); nf=nofrd(R,nf/2); end;

Algorithm explaination created using ChatGPT on 2025-08-18 22:04. (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