# Wait...where's div?

Rukiri
Posts:

**58**Member
in Programming

I'm mainly waiting for C# to move over a game maker project to Godot, but I have one question.

Doesn't GDScript have div? I know / and % is generally the same thing but they do sometimes give different results.

so... whatsup?

## Answers

158ModeratorWhat's

`div`

? Is it a division operator? If so, the only division operator I've used along all my life was just`/`

Can you show us an example of the different results you mentioned?

58Member_tileSize = 32;

_tilew = _tileSize

_tileh = _tileSize

_tileX = x div _tilew

_tileY = y div _tielh

/ works but doesn't snap the object in place like div does, also it's very common in C#, C++, etc.

1,413AdminLooking at the documentation for div (for C/C++) it looks like it divides and returns both the quotient and the remainder in a struct.

Probably the reason you're getting different values is that your using the quotient when you're calling

`div`

, while`/`

returns the quotient plus the remainder. You can get the quotient with GDScript using`floor(x / y)`

and the remainder with`(x/ y) - floor(x / y)`

, or you might be able to use`(x % y)`

to get the remainder if GDScript supports it.158ModeratorAlright, now I got, thanks @TwistedTwigleg .

Another way to get the quotient is casting the numbers to int:

`var a = 7.0 var b = 5 var quotient = int(a) / int(b) # 1`

The modulo operator

`%`

just works with integers, so to use it or you need to cast both number to integer or use`fmod()`

function.