comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » round to x number of decimals within floating point value?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: round to x number of decimals within floating point value? [message #92475 is a reply to message #92463] Wed, 23 December 2015 07:57 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
On Tuesday, December 22, 2015 at 4:17:06 PM UTC-5, omar ali wrote:
> بتاريخ الخميس، 13 يناير، 2011 8:29:29 م UTC+1، كتب Snow53:
>> I need to round the values within a file to three decimal places. For
>> example, 0.00053335 would become 0.001.
>> I also have many NaNs within the file.
>>
>> Any suggestions?
>>
>> Thanks!
>
> Hi there,
> I have gone through the messages and i wonder there is a solution to conver 0.00053335 to 0.001. Indeed, i have a number (0.2345678)and i want it to be with 2 digits after the decimal

David's solution from four years ago is still a good one...
IDL> a = 0.2345678d
IDL> print, round(a*100)/100.0d
0.23000000
Or if you just care about the printed version,
IDL> print, a, format='(D0.2)'
0.23
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: It's about time
Next Topic: GDAL spawn library conflict

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Nov 30 10:54:19 PST 2025

Total time taken to generate the page: 1.03539 seconds