<div dir="ltr">Rashed,<div><br></div><div>This is not a question of rounding.  Data type "float" in NCL is precise to only 7 decimal digits.  For this application you need to preserve 9 decimal digits, so you can not use "tofloat".  "todouble" would work fine.</div><div><br></div><div>abc  = (/"130511001","130511002","<wbr>130511003","130511004","<wbr>130511005","130511006"/)<br></div><div>cde1  = sprintf("%10f",todouble(abc))<br>cde2  = toint(cde1)<br>cde3  = toint(abc)<br></div><div><br></div><div>You could also use any of the NCL 32-bit or 64-bit integer types to preserve 9 digits: toint, toint64, etc.  Doubles will preserve 15 integer digits.  32-bit integers "integer" will preserve 9 digits.  Signed 64-bit integers "int64" will preserve 18 digits.  Unsigned 64-bit integers "uint64" will preserve 19 digits.</div><div><br></div><div>--Dave</div><div><br></div><div><br></div><div><div><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 27, 2018 at 2:29 PM, Rashed Mahmood <span dir="ltr"><<a href="mailto:rashidcomsis@gmail.com" target="_blank">rashidcomsis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi all,<br><br></div>I am wondering if there is an option to stop the function "tofloat" from rounding. Here is a simple example that explains the problem:<br><br>abc  = (/"130511001","130511002","<wbr>130511003","130511004","<wbr>130511005","130511006"/)<br>cde1  = sprintf("%10f",tofloat(abc))<br>cde2  = toint(cde1)<br>cde3  = toint(abc)<br><br>print(abc+" = "+cde1+" = "+cde2+" = "+cde3)<br><br></div>This results:<br><br>(0)     130511001 <span style="color:rgb(255,0,0)">= 130511000.000000 = 130511000</span> = 130511001<br>(1)     130511002 <span style="color:rgb(255,0,0)">= 130511000.000000 = 130511000</span> = 130511002<br>(2)     130511003 <span style="color:rgb(255,0,0)">= 130511000.000000 = 130511000</span> = 130511003<br>(3)     130511004 <span style="color:rgb(255,0,0)">= 130511008.000000 = 130511008</span> = 130511004<br>(4)     130511005 <span style="color:rgb(255,0,0)">= 130511008.000000 = 130511008</span> = 130511005<br>(5)     130511006 <span style="color:rgb(255,0,0)">= 130511008.000000 = 130511008</span> = 130511006<br><br></div>This loss of precision could be acceptable if the values were some data numbers, however, if these are unique station IDs then this is not correct.<br><br></div>I know the solution is simply use "toint" or "todouble" to avoid this situation. Just curious if a rounding option is possible in "tofloat".<br><br></div>Cheers,<br></div>Rashed</div></blockquote></div></div></div></div></div>