View unanswered posts | View active topics It is currently Fri Aug 07, 2020 6:19 am

Reply to topic  [ 2 posts ] 
printing large numbers to LCD screen 
Author Message

Joined: Sun Jul 10, 2011 3:34 pm
Posts: 30
Post printing large numbers to LCD screen
I am having a hard time printing large numbers to the VEX LCD screen with Cortex. I can only get 5 digit numbers to print. If I print a six digit number, the last number is cut off, or I get a value of 32767. I have used int, long, and float data types. I also tired to use double, but Robotc automatically converts it to a float. I cannot get it to print. Any help would be great. I placed the code below. Some of the variables come from earlier in the program. I am expecting t to be a 6 digit number.

float q = ((((nMotorEncoder[rightMotor]) + (abs(nMotorEncoder[leftMotor])))/2.0) + 250.0);
float adj = (q * 0.545666667);
long a = ((41.91*x)/177.0);
long theta = (sinDegrees(a)/cosDegrees(a));
long h = (adj*theta);

long tr = 0.5*h*adj;
long t = tr;


Fri Mar 08, 2013 2:38 pm
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post Re: printing large numbers to LCD screen
There are a couple of issues with this particular piece of code. The Long data type can only store whole integer numbers; if you attempt to store a decimal number in one, it will drop the decimal values and only store the integer value. This may result in either inaccurate or zero'd values. Another issue is that the 'displayNextLCDNumber' command can only display integer numbers, as per ROBOTC's intrinsic values:

intrinsic void displayNextLCDNumber(const int nValue, const int nPrecision = 0x40)

This is why you will see the overflow value (32767) of a integer, because you have essentially filled the memory space allocated to that variable.

Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.

Mon Mar 11, 2013 5:43 pm
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

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.