Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Math.floor and double cannot be dereferenced on compile

807598Aug 23 2006 — edited Aug 24 2006
I am trying to work with data coming from a PLC. Each item in the Array is a 16 bit word. In some cases, I need to split the 16bit word to get the pieces of data that I need. Below is my code in Javascript that was working, I am attempting to do the same thing in Java, but I am getting errors when I try to compile. The error is "double cannot be dereferenced". I have been researching the double cannot be dereferenced error, but I cannot seem to figure out how to resolve it.
I wrote some Javascript from a page that sort of worked. The problem with this is that because of the way the hardware manufacturer implements javascript and html I could not write a loop to run through 20000 PLC Registers to ge the events out. The {DTXXXX_16_S} is a specific format they allow for referencing PLC registers. The compile error points to the following statements within the Java Code
month = Math.floor(plcRegBuf[i+3] % 256).toString(16);
JavaScript
var min
var sec
var day
var hr
var yr
var month
var psi
var gpm
var dlow
var dhigh
var ew1left
var eventlogcounter=10000
var eventreg
var ew1right
var eventdesc
var register= '{DT30000_10_S}'
{
while (eventlogcounter<=29999) {
ew1left=Math.floor({DT10000_16_d}/256);
ew1right=({DT10000_16_d} % 256);
min = Math.floor({DT10001_16_d}/256).toString(16);
sec = ({DT10001_16_d} % 256).toString(16);
day = Math.floor({DT10002_16_d}/256).toString(16);
hr = ({DT10002_16_d} % 256).toString(16);
yr = Math.floor({DT10003_16_d}/256).toString(16);
month = ({DT10003_16_d} % 256).toString(16);
psi = {DT10004_16_d};
gpm = {DT10005_16_d};
dlow = {DT10006_16_d};
dhigh = {DT10007_16_d};
eventreg = (((ew1left-1)*10)+30000);
//eventdesc = "DT" + eventreg + "_10_S";
document.write ("<tr class='d1' align=center>")
document.write("<td>"+ ew1left + "<td>" + eventlogcounter + "<td>" + hr + "<td>" + min + "<td>" + sec + "<td>" + day + "<td>" + month + "<td>" + yr + "<td>" + psi + "<td>" + gpm + "<td>"+ dlow + "<td>" + dhigh);
eventlogcounter = eventlogcounter + 8
document.write("<tr  class='d0' align=center>");
document.write("<td>"+ ew1left + "<td>" + eventlogcounter + "<td>" + hr + "<td>" + min + "<td>" + sec + "<td>" + day + "<td>" + month + "<td>" + yr + "<td>" + psi + "<td>" + gpm + "<td>"+ dlow + "<td>" + dhigh);
eventlogcounter = eventlogcounter + 8
document.write (register);
}
document.write("</table>");
Java Code
for(int i=0; i<plcRcnt; i += 8)
          {
              if(ok)      //Copy new PLC values into applet layout
                   {
                   eventnum = Math.floor(plcRegBuf/256);
plcTxtDisp[i].setText(Double.toString(eventnum));
datatype = Math.floor(plcRegBuf[i] % 256);
plcTxtDisp[i].setText(Double.toString(datatype));
min = Math.floor(plcRegBuf[i+1]/256).toHexString(16);
plcTxtDisp[i+1].setText(Double.toString(min));
sec = Math.floor(plcRegBuf[i+1] % 256).toString(16);
plcTxtDisp[i+1].setText(Double.toString(sec));
day = Math.floor(parseInt(plcRegBuf[i+2]/256)).toString(16);
plcTxtDisp[i+2].setText(Double.toString(day));
hour = Math.floor(plcRegBuf[i+2] % 256).toString(16);
plcTxtDisp[i+2].setText(Double.toString(hour));
year = Math.floor(plcRegBuf[i+3]/256).toString(16);
plcTxtDisp[i+3].setText(Double.toString(year));
month = Math.floor(plcRegBuf[i+3] % 256).toString(16);
plcTxtDisp[i+3].setText(Double.toString(month));
psi = plcRegBuf[i+4];
plcTxtDisp[i+4].setText(Double.toString(psi));
gpm = plcRegBuf[i+5];
plcTxtDisp[i+5].setText(Double.toString(gpm));
dlow = plcRegBuf[i+6];
plcTxtDisp[i+6].setText(Double.toString(dlow));
dhigh = plcRegBuf[i+7];
plcTxtDisp[i+7].setText(Double.toString(dhigh));

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 21 2006
Added on Aug 23 2006
3 comments
248 views