Menu

bitwise shift using "using" for datafile

2018-08-22
2018-08-24
  • Zhang Kuang

    Zhang Kuang - 2018-08-22

    Hello I wrote my plot file, named sftest.plt,  as below (Gnuplot version: 5.2.4):

    set grid
    set autoscale
    set datafile separator ','
    set title 'My title'
    set xlabel 'Index'
    set ylabel 'Units (see labels box)'
    set style data steps
    set pointsize 0.2
    unset logscale
    set yrange [0:100]
    set xrange [*:*]
    set term push
    
    plot\
    'sftest.csv' u ($1 - 0):($2) title 'data1' with steps,\
    'sftest.csv' u ($1 - 0):($3/10) title 'data2' with steps,\
    'sftest.csv' u ($1 - 0):(($4)<<2) title 'data3' with steps
    
    set term pop
    pause -1
    

    when I run as "gnuplot sftest.plt". 
    It prompted " bit shift applied to non-INT" 
    but if I changed the line below:
    'sftest.csv' u ($1 - 0):(($4)<<2) title 'data3' with steps
    to :
    'sftest.csv' u ($1 - 0):(($4)*2) title 'data3' with steps

    It workls well.
    Does someone know if the bitwise( &, |, >>, << ) can be used with "using" keyword?
    If the bitwise cannot be used, I have to preprocess my data file.

    part of my data file "sftest.csv"

    Index,data1,data2,data3,data4,data5
    0,78,53,67,8,5
    1,78,53,67,8,5
    2,78,53,67,8,5
    3,78,53,67,8,5
    4,78,53,67,8,5
    5,78,53,67,8,5
    6,78,53,67,8,5
    7,78,53,67,8,5
    8,78,53,67,8,5
    9,78,53,67,8,5
    10,78,53,67,8,5
    11,78,53,67,8,5
    12,78,53,67,8,5
    13,78,53,67,8,5
    14,78,53,67,8,5
    15,78,53,67,8,5
    16,78,53,67,8,5
    17,78,53,67,8,5
    18,78,53,67,8,5
    19,78,53,67,8,5
    20,78,53,67,8,5
    21,78,53,67,8,5
    22,78,53,67,8,5
    23,78,53,67,8,5
    24,78,53,67,8,5
    25,78,53,67,8,5
    26,78,53,67,8,5
    27,78,53,67,8,5
    28,78,53,67,8,5
    29,78,53,67,8,5
    30,78,53,67,8,5
    

    [edited for readability-- HBB]

     

    Last edit: Hans-Bernhard Broeker 2018-08-22
    • Hans-Bernhard Broeker

      gnuplot reads data files strictly as floating-point data. That's why you can't apply integer-only operators to it. But you don't have to modify the data, either. << can always be replaced by multiplication (by 1 << operand, if you must), or you can change the data type using the int() funcction.

       
      • Zhang Kuang

        Zhang Kuang - 2018-08-22

        Thank you Hans, but I really want to get some defined bit. and I do not want to use multipication or division method to replance the bit shift.
        and I triedint() function. It still does not work.

         
  • Zhang Kuang

    Zhang Kuang - 2018-08-22

    Hello again :)
    I attached my test files. Could you please try it?

    My Gnuplot version is 5.2.4 on Windows 7

     
    • Hans-Bernhard Broeker

      The remaining problem now is the first line of your data file. Suffice it to say thatint(data3) << 4 does not make much sense, does it?

      You may want to consult 'help data skip' and/or 'help key autotitle' about what to do with that line, other than just comment it out or not generate it in the first place.

       
      • Zhang Kuang

        Zhang Kuang - 2018-08-24

        Hello Hans:
        Thank you so much. Yes, you are right. the issue casued by the first line. But I don't know why other oprands( such as +, - ,* , /) work well for the first line except bitwise( shift, and, or ) .

        Now the question comes to 'help data skip' and/or 'help key autotitle' about what to do with that line, other than just comment it out or not generate it in the first place.

        I will try to resolve this problem by myself at first. If I am blocked with this, I will come here again.

        Thank you again!

         

        Last edit: Zhang Kuang 2018-08-24

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.