<div dir="ltr">I figured that something like that was probably causing this. No, I don't need 20 digits. i was seeing data with 16 digits from KMLs.<div><br></div><div>Thanks,</div><div><br></div><div>Calvin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 15, 2021 at 11:54 AM javier <<a href="mailto:javier@panoimagen.com">javier@panoimagen.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div id="gmail-m_3095814937915020437divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<div id="gmail-m_3095814937915020437divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>Hi Calvin,</p>
<p><br>
</p>
<p>That is not related to QGIS, but to the way the CPU represents floating points numbers internally.</p>
<p>You can see the same behaviour in the Python console (or any Python interpreter, and surely almost any other programming language that uses doubles): </p>
<p>```<br>
</p>
<p>>>> v = <span>-0.1556640799496235</span><br>
</p>
<p>>>> print(f'{v:.20f}')</p>
<p></p>
<pre>-0.15566407994962350170</pre>
```
<p></p>
<p>The reason those extra digits are not '0' is because doubles are not stored in base 10, and anything beyond their standard ~16 significant digits is approximated. For a more detailed explanation you can take a look at Python documentation, they have a clear
explanation on the topic (<a href="https://docs.python.org/3/tutorial/floatingpoint.html" id="gmail-m_3095814937915020437LPlnk342318" target="_blank">https://docs.python.org/3/tutorial/floatingpoint.html</a>).
<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>If you really, really, really need 20 significant decimal places (that seems an extremely rare situation, see
<a href="https://xkcd.com/2170/" id="gmail-m_3095814937915020437LPlnk170925" target="_blank">
https://xkcd.com/2170/</a> ) you should be looking at your code really carefully, as you need a larger (in number of bits) than usual floating point type; I think that neither QGIS (or standard Python or C++) support it out of the box.</p>
<p><br>
Regards,</p>
<p>Javier<br>
</p>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_3095814937915020437divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>De:</b> QGIS-Developer <<a href="mailto:qgis-developer-bounces@lists.osgeo.org" target="_blank">qgis-developer-bounces@lists.osgeo.org</a>> en nombre de C Hamilton <<a href="mailto:adenaculture@gmail.com" target="_blank">adenaculture@gmail.com</a>><br>
<b>Enviado:</b> lunes, 15 de marzo de 2021 15:50:23<br>
<b>Para:</b> qgis-developer<br>
<b>Asunto:</b> [QGIS-Developer] Strange Behavior with QgsProcessingParameterNumber - Bug?</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>In a processing algorithm I have a double QgsProcessingParameterNumber where I have set the number of decimals metadata to be 20.</div>
<div><br>
</div>
<div>param = QgsProcessingParameterNumber(<br>
'NUMBER',<br>
tr('Number'),<br>
QgsProcessingParameterNumber.Double,<br>
defaultValue=0,<br>
optional=False)<br>
param.setMetadata({'widget_wrapper': { 'decimals': 20 }})<br>
self.addParameter(param)<br>
</div>
<div><br>
</div>
<div>In the processing popup, if I enter a number with less than 20 digits then the rest of the digits become some random number. For example if I enter</div>
<div><br>
</div>
<div>-0.1556640799496235 <br>
</div>
<div><br>
</div>
<div>the displayed result is</div>
<div><br>
</div>
<div>-0.15566407994962350170<br>
</div>
<div><br>
</div>
<div>I would think that if it pads with extra digits to fill out to 20, the digits should be 0. Have I exceeded the number of acceptable decimal digits, or is this a bug?</div>
<div><br>
</div>
<div>Thanks,</div>
<div><br>
</div>
<div>Calvin</div>
</div>
</div>
</div>
</div>
</blockquote></div>