Stream print support for 64 bit

39 views
Skip to first unread message

Collin Kidder

unread,
Jan 10, 2016, 5:18:11 PM1/10/16
to developers
I tried to print 64 bit integers on a Due and you cannot with the
print routines.

Why do the Arduino core routines not support this? You can't use
something like Serial.print to print 64 bit integers. This seems like
something that should exist. One can most certainly define 64 bit
integers and use them in Arduino sketches. Is there some reason that
64 bit integers get no love? If no compelling reason for not
supporting this exists then I'll get a pull request put together. I
plan to create all new routines specifically for 64 bit integers so
that the normal print code doesn't need to use 64 bit integers and
thus does not suffer. This is the only reason I can see that 64 bit
support would not have been added.

Matthijs Kooijman

unread,
Jan 11, 2016, 7:42:55 AM1/11/16
to devel...@arduino.cc
Hi Collin,

> I tried to print 64 bit integers on a Due and you cannot with the
> print routines.
I think I've wondered about this before and considered implementing it.
It should be a fairly trivial change, but in the current design all
number printing uses the same function (converting all numbers to 32-bit
now, I believe). This means that adding 64-bit printing will increase
size of all sketches that print numbers, even if they do not print
64-bit numbers, which could be considered a problem. I do think that
simply trying this and measuring the effect on code size of some test
sketches would be useful.

An alternative would be to have a separate 64-bit printing function, but
that again has the downside of requiring more code if you use both 64
and <= 32-bit printing in the same sketch.

Of course the same arguments can be made for having the 8-bit, 16-bit
and 32-bit printing in the same sketch, though these versions are
probable a lot more common than 64-bit printing, making the latter a bit
special.

> I plan to create all new routines specifically for 64 bit integers so
> that the normal print code doesn't need to use 64 bit integers and
> thus does not suffer. This is the only reason I can see that 64 bit
> support would not have been added.
W00ps, didn't read your message well enough the first time, you already
said pretty much what I mentioned above. A separate routing seems the
best approach to me, though perhaps you could try both approaches and
compare them?

Gr.

Matthijs
signature.asc

Pieter van der Meer

unread,
Jan 11, 2016, 8:09:06 AM1/11/16
to devel...@arduino.cc
to be honest i never bothered with the serial.print family again, once i knew printf() is used under water.. power users wouldn't care. beginners would probably not encounter cases where they'd need 64 bit. just my 0.02 euro.


--
You received this message because you are subscribed to the Google Groups "Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to developers+...@arduino.cc.



--

Pieter van der Meer
Tasty Chips Electronics
Reply all
Reply to author
Forward
0 new messages