Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

hey why does a multiplication of a negative float by 0 return -0.0,how can i solve the problem..? e.g.- -2.0*0 returns -0.0

OpenStudy (anonymous):

i know -0.0 is same as 0.0 but why does it print a negative sign in the front...

OpenStudy (anonymous):

anyone???

OpenStudy (anonymous):

I don't know the answer to your question, but if you require a positive integer you could always resort to the absolute function.

OpenStudy (anonymous):

It prints -0.0 because this is just a representation. In fact, if you use the 'repr()' command on your variable, you will see that you result is something like "-0.000000000xxxxx"! This is due to number representation in python. "print" just outputs a short representation! For more, see lecture 7 video of the 6.00SC course material!

OpenStudy (anonymous):

ok thanks...

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!