Go Down

Topic: Proposed update for the printFloat code of print.cpp (Read 7998 times) previous topic - next topic

dariosalvi

Hi,

how do I use this library?

if I just import it, I can't instantiate any Print object because it's virutal...

Any suggestion?

aweatherguy

You don't directly instantiate it. This is a replacement for the Print.cpp file in the hardware/arduino/avr/cores/arduino directory. You overwrite the files in that directory with the new ones. This re-defines the print class which propagates to Serial, HardwareSerial and so on.

If you do this, then you must do it again everytime you update the Arduino IDE installation because that will re-install a default Print.cpp file.

robtillaart


Included updated code for print.cpp and print.h work with IDE 1.8.1
This is not the latest version IDE and I will check 1.8.5 compatibility a.s.a.p.

This code also prints 64 bit integers, signed and unsigned.
(so you can get that prime sieve beyond 32 bit)

Unfortunatelly I did not have time to test all integers and floats ;)
so remarks and comments are welcome.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart

#18
Oct 09, 2017, 01:45 pm Last Edit: Oct 09, 2017, 01:45 pm by robtillaart
Checked compatibility with IDE 1.8.5 ==> OK
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

seradu

aweatherguy.... I follow your instruccions and replace both files print.h and print.cpp into my directory

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino... but it is still not working.


My example code is:


double Wo = 500;
double L5 ;   
double resultado;     

void setup()
        {
            Serial.begin(9600);
        }

void loop()

        {
            L5 = pow(Wo,5);
            Serial.println(L5);
            resultado = L5 - (L5-2);//31249999999999;
            Serial.println(resultado);
            while(1);
        }


And the serial monitor is showing

ovf
2.00



I even try removing the files (print.h, print.cpp) from the directory, expecting to see a error message. But de IDE still showing


ovf
2.00


Go Up