View unanswered posts | View active topics It is currently Mon Nov 24, 2014 8:37 am






Reply to topic  [ 3 posts ] 
nxtDisplayCenteredTextLine does not display franctions 
Author Message
Rookie

Joined: Sat Apr 26, 2014 8:53 pm
Posts: 1
Post nxtDisplayCenteredTextLine does not display franctions
nxtDisplayCenteredTextLine(4, "Speed = %f", (0.12)); // display text to the LCD screen


Sat Apr 26, 2014 9:00 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3289
Location: Rotterdam, The Netherlands
Post Re: nxtDisplayCenteredTextLine does not display franctions
It displays the value exactly as it should on my NXT.
Attachment:
2014-04-27 06.58.48.jpg
2014-04-27 06.58.48.jpg [ 1.04 MiB | Viewed 663 times ]


If you want fewer decimal points, you can try printing like this:
Code:
task main()
{
  nxtDisplayCenteredTextLine(4, "Speed = %f", (0.12)); // display text to the LCD screen
  nxtDisplayCenteredTextLine(5, "Speed = %.2f", (0.12)); // Use only two decimals points
  while(true);
}


= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Sun Apr 27, 2014 1:01 am
Profile WWW
Moderator
Moderator

Joined: Thu Jan 03, 2013 5:10 pm
Posts: 198
Location: The plateau north of the Ohio River Valley, also known as Cave Country.
Post Re: nxtDisplayCenteredTextLine does not display franctions
"%f" displays floating point numbers, not fractions. Most computers do not have built-in fractions types, so you must program your robot to convert values to fractions with your own code.

_________________
I'm not a robot! I'm british! ~ quote from an asparagus
I am not a robot! I am a unicorn! ~ quote from a robot


Sun Apr 27, 2014 6:24 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.