In integer math, 59/2 = 29. You aren't saving the result in a float, or type casting the result as a float. "%f" tells the function to format the value as a float, but the parameter you are passing is integer (i.e. 59/2).

_________________Matt

Sat Jul 13, 2013 11:05 am

Ernest3.14

Professor

Joined: Sat May 18, 2013 1:24 pmPosts: 271Location: Olympia, WA

Re: Why 59/2=29.0 in %f

A quick way to fix this would be to use:

Code:

nxtDisplayTextLine(3,"%f",(float)59/2);

Of course, if these things bother you, you're welcome to convert ("cast") both numbers to a float.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum