Deprecated: Function get_magic_quotes_runtime() is deprecated in /home/public/forums/include/common.php on line 79

Deprecated: Function get_magic_quotes_gpc() is deprecated in /home/public/forums/include/common.php on line 83
is_int / Script Submission / GMLscripts.com

GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2022-04-01 08:39:46

gnysek
Member
Registered: 2011-12-29
Posts: 25

is_int

Expandfunction is_int(number) {
    return sign(frac(number)) == 0;
}

results:

Expandshow_debug_message(is_int(1)); // 1
show_debug_message(is_int(1.0)); // 1
show_debug_message(is_int(1.1)); // 0
show_debug_message(is_int(-1)); // 1
show_debug_message(is_int(-1.0)); // 1
show_debug_message(is_int(-1.1)); // 0
show_debug_message(is_int(0)); // 1

Offline

#2 2022-04-09 06:02:20

maras
Member
Registered: 2021-04-25
Posts: 25
Website

Re: is_int

Hmm wouldn't this be a little bit faster?

Expand return floor(number) == number; 

I'm on the official GM discord > maras#5104

Offline

Board footer

Powered by FluxBB