You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since inheriting Arduino's Printable would incur a ridiculously unnecessary overhead (2 bytes per object to provide the pointer to the virtual table) I'll most likely either use named functions (e.g. printFractional(printer, fixed)) or make use of << as an output operator in the style of C++'s std::ostream.
Being able to provide printing in a decimal format would be ideal, but at present I'm not sure how to do that beyond casting to float, so I may have to abuse that as a stop-gap. Hopefully I'll have time to research how floating point printing works to see if I can learn anything useful that could be applied to printing fixed points in a decimal format.
If I can't manage to find a way to implement decimal format printing then I'll just stick to the fractional representation because it's easy to implement, relatively cheap (it's mostly just bit shifting and integer printing) and reasonably easy to understand.
The text was updated successfully, but these errors were encountered:
I'm getting a little fed up with having to put
static_cast<float>
everywhere when debugging so I'd like to find a means to print fixed points.Implementing printing in fractional form should be pretty straightforward in most cases.
Something like this ought to work for most cases:
Since inheriting Arduino's
Printable
would incur a ridiculously unnecessary overhead (2 bytes per object to provide the pointer to the virtual table) I'll most likely either use named functions (e.g.printFractional(printer, fixed)
) or make use of<<
as an output operator in the style of C++'sstd::ostream
.Being able to provide printing in a decimal format would be ideal, but at present I'm not sure how to do that beyond casting to
float
, so I may have to abuse that as a stop-gap. Hopefully I'll have time to research how floating point printing works to see if I can learn anything useful that could be applied to printing fixed points in a decimal format.If I can't manage to find a way to implement decimal format printing then I'll just stick to the fractional representation because it's easy to implement, relatively cheap (it's mostly just bit shifting and integer printing) and reasonably easy to understand.
The text was updated successfully, but these errors were encountered: