Jump to content

Floating point maths


xigaro
 Share

You are about to reply to a thread that has been inactive for 4277 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Because even though you have declared your variable example to be a float, the numbers 1 and 11 are not. They are integers.  If you divide an integer by an integer, the result is an integer rounded down to the nearest integer.  In this case,

1/11 = 0  .

If you want a realistic float result, write float example = 1.0/11.0;

1.0/11.0 = 0.090909090909

Edit:  Hah!   Dora is faster today.  :smileylol:

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4277 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...