<p>neels <strong>uploaded patch set #3</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/20331">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add osmo_float_str_to_int() and osmo_int_to_float_str_*()<br><br>This will be useful to handle latitude and longitude numbers for GAD, which is<br>the location estimate representation used for LCS (Location Services).<br><br>The OsmoSMLC VTY user interface will provide floating-point strings like<br>"23.456" while GAD stores them as micro-degress 23456000. The osmo_gad_to_str*<br>will also convert latitude and longitude to floating-point string.<br><br>There was code review concerns against adding this API, upon which I tried to<br>use floating point string formats. But I encountered various problems with<br>accuracy and trailing zeros. For global positioning data (latitude and<br>longitude), even inaccuracy on the sixth significant decimal digit causes<br>noticeable positional shift. To achieve sufficient accuracy on the least<br>significant end, I need to use double instead of float. To remove trailing<br>zeros, the idea was to use '%.6g' format, but that can cause rounding. '%.6f'<br>on a double looks ok, but always includes trailing zeros. A test program shows:<br><br> %.6g of ((double)(int32_t)23230100)/1e6 = "23.2301"     <-- good<br> %.6g of ((double)(int32_t)42419993)/1e6 = "42.42"       <-- bad rounding<br> %.6g of ((double)(int32_t)23230199)/1e6 = "23.2302"     <-- bad rounding<br><br> %.6f of ((double)(int32_t)23230100)/1e6 = "23.230100"   <-- trailing zeros<br> %.6f of ((double)(int32_t)42419993)/1e6 = "42.419993"   <-- good<br> %.6f of ((double)(int32_t)23230199)/1e6 = "23.230199"   <-- good<br><br>It looks like when accepting that there will be trailing zeros, using double<br>with '%.6f' would work out, but in the end I am not certain enough that there<br>aren't more hidden rounding / precision glitches. Hence I decided to reinforce<br>the need to add this API: it is glitch free in sufficient precision for<br>latitude and longitude data, because it is based on integer arithmetic.<br><br>The need for this precision is particular to the (new) OsmoSMLC vty<br>configuration, where reading and writing back user config must not modify the<br>values the user entered. Considering to add these functions to osmo-smlc.git,<br>we might as well add them here to libosmocore utils, and also use them in<br>osmo_gad_to_str_*() functions.<br><br>Change-Id: Ib9aee749cd331712a4dcdadfb6a2dfa4c26da957<br>---<br>M include/osmocom/core/utils.h<br>M src/utils.c<br>M tests/utils/utils_test.c<br>M tests/utils/utils_test.ok<br>4 files changed, 1,000 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/31/20331/3</pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/20331">change 20331</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/20331"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ib9aee749cd331712a4dcdadfb6a2dfa4c26da957 </div>
<div style="display:none"> Gerrit-Change-Number: 20331 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: neels <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: laforge <laforge@osmocom.org> </div>
<div style="display:none"> Gerrit-CC: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>