TinyCircuits Forum

General Category => General Discussion => Topic started by: jgavlik on October 09, 2019, 12:34:57 PM

Title: How to determine the width of a float number
Post by: jgavlik on October 09, 2019, 12:34:57 PM
I'm using the TinyScreen+ and would like to determine the width of a float number (with 2 places to the right of the decimal). 

Looks like you can do this with strings as in
  int width=display.getPrintWidth("Example Text!");

So is there a similar way to do it with float numbers??

Thanks,

John
Title: Re: How to determine the width of a float number
Post by: lennevia on October 17, 2019, 01:26:36 PM
Hey John,

A simple workaround could be converting the floating number to a char: https://stackoverflow.com/questions/2988791/converting-float-to-char

So you can continue using the same function.

Hope that works for you!

-RĂ©na
Title: Re: How to determine the width of a float number
Post by: jgavlik on October 18, 2019, 12:06:46 PM
I'll try it...thanks...john