#Java

1 messages · Page 1 of 1 (latest)

dense cipherBOT
#

<@&987246399047479336> please have a look, thanks.

torpid shore
#

integer division

#

ok

jaunty dome
#

I use calculator to calculate and get the answer is 95 but why after run the system give me the answer is 67 ? Help 🙏

torpid shore
#

as I already said your problem is 9 / 5

#

its using integer division

#

which will evaluate to 1

#

if you instead do 9.0 / 5.0 you will get 1.8

jaunty dome
#

But 1.8 mathematical carry not became 2 ?

torpid shore
#

what?

#

1.8

#

is 1.8

real torrent
#

there's Math.ceil if you want to round up

jovial kestrel
#

Some examples:

  • 21/2 would be 10.5, but integer division makes it 10
  • 10/3 would be 3.333... but integer division makes it 3
  • 1/4 would be 0.25 but integer division makes it 0

You see?

graceful zealot
true osprey