<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Hi Steve,</p>
<p><br>
</p>
<p>thanks for looking into this. I also tried to find a sample case where this code is needed,</p>
<p>without success, but that is probably caused by the filters.<br>
</p>
<p>Still, I also think we can remove the code, the test will only find cases</p>
<p>where the offset doesn't fit into e.g. 24 bits for resolution 24, but the limit is much smaller</p>
<p>- I think <span>32768</span>, so 15 bits  - and it is tested again later in MapObject:</p>
<p></p>
<div></div>
<div>    protected void setDeltaLong(int deltaLong) {<br>
        assert deltaLong >= -0x8000 && deltaLong <= 0x7fff : "deltaLong = " + deltaLong;<br>
        this.deltaLong = deltaLong;<br>
    }<br>
</div>
<p></p>
<p><br>
</p>
<p>Gerd<br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> mkgmap-dev <mkgmap-dev-bounces@lists.mkgmap.org.uk> im Auftrag von Steve Ratcliffe <steve@parabola.me.uk><br>
<b>Gesendet:</b> Mittwoch, 20. Juli 2016 23:30:24<br>
<b>An:</b> Development list for mkgmap<br>
<b>Betreff:</b> Re: [mkgmap-dev] Bit operatons in mkgmap</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
Hi Gerd<br>
<br>
> I'd like to change this code in LinePreparer (and a copy in<br>
> LinePreparerFilter)<br>
><br>
>             // XXX: relies on the fact that java integers are 32 bit signed<br>
>             final int offset = 8+shift;<br>
> to<br>
><br>
>             final int offset = (Integer.SIZE - 24) + shift;<br>
><br>
> As you see I assume the value 8 is the result of 32 - 24.<br>
> and I guess that 24 is the maximum resolution.<br>
> Maybe we have a proper constant for that ?<br>
<br>
Yes I think that it is supposed to be the difference between the 24<br>
bit size of the Garmin word and the 32 bit java int.<br>
<br>
But... does the following code that uses that value actually<br>
work?<br>
<br>
                        int dx = (lon - lastLong) << offset >> offset;<br>
                        int dy = (lat - lastLat) << offset >> offset;<br>
<br>
I assume that the intent is to sign extend the value, but the way the<br>
value is calculated they should be already properly signed values.<br>
<br>
If the dx, dy values are too big, they will be corrupted by the shift<br>
operations. However the following assertions:<br>
<br>
        assert (dx == 0 && lon != lastLong) == false: ("delta lon too large: " <br>
+  (lon - lastLong));<br>
        assert (dy == 0 && lat != lastLat) == false: ("delta lat too large: " + <br>
  (lat - lastLat));<br>
<br>
claim to be a test for the delta being too large, but this cannot work<br>
either.<br>
<br>
But that is just looking at the code... I added a test to see if<br>
there was ever a difference between the plain (lon - lastLong) value<br>
and the double shifted value.  None found on compiling a UK map.<br>
<br>
So I think that 'offset' can be removed entirely unless you can see a<br>
case where it is needed?<br>
<br>
..Steve<br>
<br>
_______________________________________________<br>
mkgmap-dev mailing list<br>
mkgmap-dev@lists.mkgmap.org.uk<br>
<a href="http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev">http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev</a><br>
</div>
</span></font>
</body>
</html>