faster printing of floats by divmod10() and others

robtillaart:

  1. For this behaviour I would like to add a new format e.g. DEFSCI so that the DEF behavior is 100% backwards compatible.
  2. the lower limit should be higher 0.01 as printing with 2 decimals is I think most used.

Can you post your print.h/.cpp so I can give it a try here?

(My time=536 yours time=448, want to understand why yours is so much faster?)

sure, make changes as you see fit.... i've attached my files. you will notice that I've gone over the core library and changed certain parameters to calls reducing size being used. the int down to 8bit for example.
another speed up is using bool, instead of the stock defined boolean, which is typedef by default on unsigned char ( uint8_t ) duh !

i use a macro based hardware serial, and for writing, i don't buffer... i do however run my serial port at 1,000,000 baud, so a probable speed up, altho on default TX & RX buffering, I think I remember the buffers being 32 byres in size. ( iuse a mega 2560 frequently, so wanted the RAM, so I explicitly define each serial port I want live. and I only buffer RX. so perhaps my faster baud rate ( with busy polling to write the next byte ) doesn't actually gain much over the buffer TX version. I know my hardware serial replacement saves over 500bytes.

Print.cpp (5.8 KB)

Print.h (6.63 KB)

HardwareSerial.h (9.69 KB)