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

Home » Public Forums » archive » floats from strings... duh!
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: Floats [message #47985 is a reply to message #47854] Thu, 09 March 2006 03:10 Go to previous messageGo to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Mark Hadfield wrote:
> Paul Van Delst wrote:
>> Sheldon wrote:
>>>
>>> Here is a silly question: Can I define a float array and control how
>>> many decimal places are kept? For example, I want all values to only
>>> have an accuracy to the nearest 100th (20.15 and not 20.154983445).
>>> Kind of like in printing, you know, the f5.2 print definition, but only
>>> for variables and arrrays.
>>
>> May I ask why? Usually this sort of thing is required for printing, but
>> not for regular old storage of numbers.
>
> Currency?

If you require exact results in cents, you shouldn't usea float number
representing the number of dollars, you should use a long number
representing the number of cents. You'll need to use a floating point
type for intermediate calculations if you're doing things like
computing compound interest. Keep in mind that FLOAT usually doesn't
have enough precision for such calculations: use DOUBLE instead.
However, if you want to display a long series of numbers, and print a
correct total for the displayed numbers, you'd better use an integer
type.
There are languages which provide direct support for fixed-point types.
They use an underlying integer type to represent a number with a fixed
number of digits after the decimal point. IDL isn't one of those
languages.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: matching 2 grids
Next Topic: Solaris 10

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

Current Time: Thu Oct 09 23:09:55 PDT 2025

Total time taken to generate the page: 1.04273 seconds