# GMLscripts.com

Discuss and collaborate on GML scripts

You are not logged in.

## #1 2009-01-05 18:30:24

xDanielx
Member
Registered: 2009-01-02
Posts: 38

### is_factor -- handling non-integers

Currently this works for integers but not all reals. The ! operator returns true if the operand is less than or equal to 0.5, so !(3.2 mod 1) --> !(0.2) --> 1, indicating that 1 is a factor of 3.2. I would either make the qualification explicit by replacing "real" with "integer", or generalize it to work with all reals by doing

return (argument1 mod argument0 == 0);

I know the rhetoric of factorization is generally associated with integers, but might as well tweak it to worth with all numeric inputs.

Last edited by xDanielx (2009-01-05 18:30:44)

Offline

## #2 2009-01-05 22:02:49

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

### Re: is_factor -- handling non-integers

It's not a feature, it's a bug. Nice find.

The way you are doing it is the way it should have been done in the first place.

I'll make the change in a few days if nobody has a problem with it or can provide a better solution.

Abusing forum power since 1986.

Offline

## Board footer

Powered by FluxBB