<html>
<head>
<base href="https://bugs.freedesktop.org/" />
</head>
<body><span class="vcard"><a class="email" href="mailto:thomas@kluyver.me.uk" title="Thomas Kluyver <thomas@kluyver.me.uk>"> <span class="fn">Thomas Kluyver</span></a>
</span> changed
<a class="bz_bug_link
bz_status_NEW "
title="NEW - FILEOPEN: read error for unsupported Lotus123 .wk3, .wk4"
href="https://bugs.freedesktop.org/show_bug.cgi?id=55786">bug 55786</a>
<br>
<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>What</th>
<th>Removed</th>
<th>Added</th>
</tr>
<tr>
<td style="text-align:right;">CC</td>
<td>
</td>
<td>thomas@kluyver.me.uk
</td>
</tr></table>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - FILEOPEN: read error for unsupported Lotus123 .wk3, .wk4"
href="https://bugs.freedesktop.org/show_bug.cgi?id=55786#c13">Comment # 13</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - FILEOPEN: read error for unsupported Lotus123 .wk3, .wk4"
href="https://bugs.freedesktop.org/show_bug.cgi?id=55786">bug 55786</a>
from <span class="vcard"><a class="email" href="mailto:thomas@kluyver.me.uk" title="Thomas Kluyver <thomas@kluyver.me.uk>"> <span class="fn">Thomas Kluyver</span></a>
</span></b>
<pre>I had to spend a while digging into an old WK4 file to extract some data. I
thought I'd document my main finding here:
opcode 0x17 appears to be a 10-byte extended precision float. After the record
header, there is a two byte row number, one byte sheet number, and one byte
column number. These are common to a few record types. The remainder of it is
the value, in the format described here:
<a href="http://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format">http://en.wikipedia.org/wiki/Extended_precision#x86_Extended_Precision_Format</a>
I was able to extract these, at least for the small positive numbers in my
sample, using the following Python code:
a = int.from_bytes(r.data[-2:], 'little')
sign = -1 if (a & (1<<15)) else 1
e = a - (a & (1 << 15)) - 16383
m = int.from_bytes(r.data[4:-2], 'little')
val = m / (1<<(63-e))
0x16 is a label, with the same row/sheet/column fields.
I started looking into making a patch, but I got confused because there appear
to be opcode lookup tables both in optab.cxx and as switch statements in
lotread.cxx, with different opcodes in them.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>