Little bug in example code "Simple data plotter"


#1

I think there is a little bug in the example code “Simple data plotter” on http://www.ulisp.com/show?2CYW

In the last line of function ‘tst’ the ‘ash’ function receives a float, resulting here in an error that it wants an integer. Adding an ‘truncate’ or ‘floor’ solves it.

But maybe I’m missing something because I see the same construct used in the previous version of the example.


#2

The function was originally written on the AVR version of uLisp which doesn’t have floating-point numbers, so division gave an integer result. The best solution, for portability, would be to change each occurrence of / to truncate. Thanks for pointing this out.


#3

But maybe I’m missing something because I see the same construct used in the previous version of the example.

Can you give me a link to that - I should fix that too. Thanks!


#4

Thanks for your reaction, and for sharing uLisp ofcourse. The old example with the same “issue” is at webpage Simple data plotter for 128x64 OLED display


#5

Thanks! I’ve fixed those too.


#6

That is quick. Is a ‘truncate’ around the ‘ash’ not enough ?


#7

That would certainly work, but since the original program was designed for AVR uLisp which doesn’t have floating point, its more consistent to change the / operator to truncate.


#8

I understand. Thank you for the explanation.


#9