Start a new topic

Decimal numbers


Can you give a value to the numbers in decimal format?

exampleCan you give a value to the numbers in decimal format?





no, Nextion logic is integer based ...


out of curiosity ...

what's the reason why you didn't just type "main.n1.val+0,5" in your Editors Debugger and observ the result instead of open a long thread ... ?


1 person likes this

I do not understand...

I tried but I get the error:

Error: Invalid Variables: main.n1.val = main.n1.val + 0.5 (Double click to jump to code)

Error: Compile failed! 1 Errors, 0 Warnings,

That's exactly what you should understand! If the IDE does not compile and throws an error, that means that either you did something wrong, or, as in that case, you are trying to do something impossible.

When you need to display fractional values on the Nextion, the corresponding calculus must be done in your MCU (Arduino or whatever) because the Nextion can -as stated - only work with integers. To display such numbers, put a text field on the Nextion and write your number converted to text from the MCU. Useful function for formatted conversion of decimal numbers to text in C/C++ is the printf function and its companions.

1 person likes this

In fact my question was whether it can be done,

And if there were any other possibilities ...


Now I know that I can not do it from Nextion and will do it to "outside" Nextion




sorry, you are missleading .....

    - the Nextion can't do native float calculations ...

    - but you surely can calculate with floats on the Nextion ...

this 2 is NOT the same ...

"Stump the Chump" even shows examples of plain Nextion calculators with float support ...

You are right Gerry (as always)! 

But depending on the used MCU, there is IMHO no or little interest to do calculation with floats on the Nextion. For example, the Teensy 3.6 has a FPU and needs 12 cycles @180MHz = 67ns for a float-by-float division. I don't think that this can be done quicker in the Nextion... ;-) 


you are surely right, no need to compare the speed of an interpreted code with a compiled native one ...

Nextion HMI displays also have never been designed to work as "Number Cruncher" ...
but for a few simple float calculations even a Nextion HMI Interpreted code has enough "horse power" to do things in reasonable time ...

and indeed it is not the same to say "it can't be done" or "it can be done, a bit more slowly than native, but still reasonable" ...



Perhaps the fact teensy 3.6 may be able to do at 67ns but also ponder and take baudrate into consideration.  Depending on the baudrate, by the time it takes to do a fetch-calculate-return I can have Nextion perform said +0.5 and start drawing cartoons. =)

The debate might look at the "can it" be done

 - as an input of 0.5, not without additional code

 - as a calculation, again not without additional code

Such additional code is either MCU side or Nextion side

 - but indeed needs additional code

Now Gerry and I proved "we did",

   seems you have enough that "you can"

- so the user question of "can" boils down to user skills

Login or Signup to post a comment