Page 1 of 1

Bitwise calculations

Posted: Thu Jun 13, 2013 2:45 am
by joma
Hi,

it would be great :D (and add much value to Dplot :!:) if one could do bitwise calculations (AND, OR, XOR, SHIFT) on the data using the "operate on ..." command (and of caus for funktion f(x) ... as well). This would e.g. allow to check for closed/opened ports in a microcontroller based system, one could even think if some sort of logic analyser.

Greetings

Jo

Posted: Thu Jun 13, 2013 9:04 am
by DPlotAdmin
That's easy enough - I'll look into it.

The only catch I can think of is the input would have to be truncated to an integer for these to make sense.

Thanks

Posted: Fri Jun 14, 2013 4:48 am
by joma
Hi David,

great news! I'm looking forward to try it. Of cause there has to be an intrinsic truncation in the function (like "(long)floor(y)" or sth. like that)

With best regards

Jo :D

Posted: Sat Jun 15, 2013 10:20 pm
by DPlotAdmin
Here is the first stab at it showing AND and OR functions with a simple example. XOR and NOT are also in there, but not shown simply because the graph gets too messy.

Image

If you have a real-world meaningful example you'd like to try out, send it to me. Or you can try out the new function parser yourself. Exit DPlot if it is running and download http://www.dplot.com/fparser.dll and save to the folder where dplot.exe resides, overwriting the existing version.

Syntax, in C-speak:
AND(y,z) returns (floor(y) & floor(z))
NOT(y,z) returns (floor(y) & ~floor(z))
OR(y,z) returns (floor(y) | floor(z))
XOR(y,z) returns (floor(y) ^ floor(z))

And thanks for the suggestion.

Posted: Mon Jun 17, 2013 2:10 am
by joma
Hi David,

many thanks for your first version. It just works fine if one uses the dot as decimal symbol. But as you may know, I live in Germany, and therefore - unfortunately - our data use the decimal comma. With this as setting under options, one only gets (different) errror messages using the bitwise calculations.

Greetings

Jo

Posted: Mon Jun 17, 2013 7:47 am
by DPlotAdmin
That's how all functions (and macro commands) work and this is not likely to change.

Posted: Tue Jun 18, 2013 12:35 pm
by DPlotAdmin
Correction. This:
NOT(y,z) returns (floor(y) & ~floor(z))

makes no sense to do. Now

NOT(y) returns ~floor(y)

If you want the previous answer you could use AND(y,NOT(z))

This will be available soon - probably this coming weekend.