SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/01/2019, 06:34 PM   #1
Kevinas100
Little Clucker
 
Join Date: Oct 2015
Posts: 36
Reputation: 7
Default dividing numbers

hi , I want to do something like let's say if(4%2 == 0)
but samp doesn't have the function of % dividing, is there another available option?
Kevinas100 is offline   Reply With Quote
Old 09/01/2019, 07:23 PM   #2
Chyakka
Big Clucker
 
Join Date: Jul 2015
Location: England
Posts: 61
Reputation: 10
Default Re: dividing numbers

% is used for modulo and / is used for division.

Using
Code:
if(4%2 == 0) //do whatever
Is completely valid in PAWN.
Chyakka is offline   Reply With Quote
Old 10/01/2019, 12:04 PM   #3
Kevinas100
Little Clucker
 
Join Date: Oct 2015
Posts: 36
Reputation: 7
Default Re: dividing numbers

Quote:
Originally Posted by Chyakka View Post
% is used for modulo and / is used for division.

Using
Code:
if(4%2 == 0) //do whatever
Is completely valid in PAWN.
I forgot it's called modulo, but what about floats?
Kevinas100 is offline   Reply With Quote
Old 10/01/2019, 12:34 PM   #4
Kaliber
High-roller
 
Kaliber's Avatar
 
Join Date: Jun 2012
Location: Localhost
Posts: 1,092
Reputation: 156
Default Re: dividing numbers

For dividing, use https://wiki.sa-mp.com/wiki/Floatdiv

Modulo Operation on Floats makes no sense, cause you have no remainder
__________________
Kaliber is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with dividing two integers vannesenn Scripting Help 6 02/01/2016 11:09 PM
Dividing numbers that will result a float ? Ahmad45123 Scripting Help 5 08/01/2015 07:19 PM
The Divide sign is not dividing? Shoulen Scripting Help 2 03/04/2013 01:05 PM
Dividing a string into 2 arrays? Deal-or-die Scripting Help 1 02/09/2012 03:29 PM
[Discussion] 0 dividing bug... InferNus` Scripting Help 17 11/02/2012 03:56 PM


All times are GMT. The time now is 07:42 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.