Decimal display

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
clemmi
 
Posts: 8
Joined: Sun Aug 11, 2013 12:21 pm

Decimal display

Post by clemmi »

Hi,

I have 1.8" Color TFT Display Shield Shield w/joystick and an Arduino Uno and it displays float numbers with 2 decimals (i.e, -2.45).
How can I make it display 4 decimals (i.e., -2.4523)?
I tried:
tft.print(varCount,4); but it didn't work.

tft.print(varCount/360); works fine but only 2 decimals. So it takes variables and do the math.

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Decimal display

Post by adafruit_support_mike »

tft.print( number, digits ) is the correct way to do it. None of our code actually handles the logic of deciding how to print a number.. that lives in the Print class (Print.h and Print.cpp). Our code provides the glue necessary to translate the Print class's commands into pixels on a specific display.

Post the code you're using and we'll see if we can find anything there.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”