-4

enter image description here

Is there a rule when you divide that the + becomes - or something like that, because i dont get it how does it print 0.250

Eugene Sh.
  • 17,802
  • 8
  • 40
  • 61
  • 1
    Post the code as text in the question. – Eugene Sh. Nov 25 '21 at 17:10
  • 5
    https://www.autodraw.com/share/IT1MN5NM2W3N – pmg Nov 25 '21 at 17:11
  • 2
    `1/2` is `0` - don't do integer math if you want `float` results – UnholySheep Nov 25 '21 at 17:11
  • In your own words, when you wrote `1/4.0`, why did you write that, rather than writing `1/4`? Do you see why the same issue applies to writing `1/2` rather than `1/2.0`? – Karl Knechtel Nov 25 '21 at 17:12
  • Welcome to Stack Overflow. [Please do not upload images of code/errors when asking a question.](//meta.stackoverflow.com/q/285551) It is also a good idea to make sure you understand the fundamentals of the language you are learning: Stack Overflow is not a tutorial resource. – Karl Knechtel Nov 25 '21 at 17:13
  • its from a test I did not write this code, that's why I am little bit confused – Reckless Nov 25 '21 at 17:15

1 Answers1

0

1/2 1 and 2 both are integers so they evaluates to 0
beacuse of this x= 0 + 0.250 gives the result 0.250

Nit_esh
  • 105
  • 5