Problem with division

Monkey Forums/Monkey Programming/Problem with division

Soap(Posted 2011) [#1]
I've tried to divide two numbers and it just ends up giving me 0.
Print((SCREEN_WIDTH/background.Width())+":"+SCREEN_HEIGHT+":"+background.Height())
this prints this: 0:480:768
It shouldn't return 0.


muddy_shoes(Posted 2011) [#2]
What are those numbers? Floats? Ints? Are you familiar with integer division versus floating point division and their behaviours? If not, you should have a read of the section on mathematical operations on pg 20. of "Get Started With Monkey" under "Tutorials and Articles" in the Monkey docs.

Just as an aside, it would be nice if the docs were also on the site here so we could just link.


Soap(Posted 2011) [#3]
Perfect, thanks!
On that note of documentation, it would be nice if there was a reference that showed what each thing is and what it does. For starters I didn't know what image.Width() was.


muddy_shoes(Posted 2011) [#4]
Agreed, I would also appreciate it if the documentation explicitly stated type information and also didn't use the symbolic shorthand versions (feel free to entirely remove them from the language, in fact).

Soap, if a type isn't stated then you can generally assume that it's an Int as Monkey defaults to that type.


Soap(Posted 2011) [#5]
In this case it's a float. I was using an int before.


matt(Posted 2011) [#6]
Mark has said in the past that he had reservations about posting the docs publicly - particularly the mojo ones. I'd be interested to see if he still feels that way?

I feel documentation in general still needs a lot of work by a dedicated person or persons.