jdbf
jdbf copied to clipboard
Problem reading Double solved
Hi, First of all, thank you to iryndin for sharing his great work.
I was having problem reading Double values from a dbf, so I solved it adding this in "DbfRecord.java":
At toMap() method, I have added the following case:
case Double: map.put(name, getDouble(name)); break;
And these new methods:
public Double getDouble(String fieldName) {
byte[] bytes = getBytes(fieldName);
return Double.longBitsToDouble(readLong(bytes));
}
protected long readLong(byte[] bytes) {
long value = 0;
value += (long) (bytes[7] & 0x000000FF) << 56;
value += (long) (bytes[6] & 0x000000FF) << 48;
value += (long) (bytes[5] & 0x000000FF) << 40;
value += (long) (bytes[4] & 0x000000FF) << 32;
value += (bytes[3] & 0x000000FF) << 24;
value += (bytes[2] & 0x000000FF) << 16;
value += (bytes[1] & 0x000000FF) << 8;
value += (bytes[0] & 0x000000FF);
return value;
}
I hope this will help you.
Regards.
i made a small modification to your code in my personal project, i cast all those bytes to long and it works for me thx