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

Home » Public Forums » archive » FORMAT FLOATS TO STRINGS WITH 3 DIGITS ONLY
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
FORMAT FLOATS TO STRINGS WITH 3 DIGITS ONLY [message #44193] Sun, 22 May 2005 18:01 Go to next message
Giorgos is currently offline  Giorgos
Messages: 8
Registered: April 2005
Junior Member
Hi

I have the following problem....
I have an array of float numbers consisting of many decimal points and
I want to convert it to string ... I used the string command but how
can I isolate and keep only the first 3 digits from each element of the
array? I played with the format keyword but... a mess...
can anyone help?
Re: FORMAT FLOATS TO STRINGS WITH 3 DIGITS ONLY [message #44223 is a reply to message #44193] Thu, 26 May 2005 07:05 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
Well... the original poster did not say that he/she wanted only the
first 3 most significant digits, just the first 3 digits... so I
thought strmid() was the simplest answer:

first3 = strmid(string(var),0,3)
Re: FORMAT FLOATS TO STRINGS WITH 3 DIGITS ONLY [message #44235 is a reply to message #44193] Wed, 25 May 2005 10:44 Go to previous message
Benjamin Hornberger is currently offline  Benjamin Hornberger
Messages: 258
Registered: March 2004
Senior Member
hradilv wrote:
> I'm sorry (I make this mistake all the time) I meant "strmid()"
>

I'm not sure why one would use STRMID in this case -- you can use it to
cut out substrings, but why not format correctly in the first place
rather than specifying too many digits first and then cutting off what
you don't want?

Benjamin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: isurface transparency not showing lines and points
Next Topic: Re: help: window content erased after resize

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

Current Time: Wed Oct 08 17:38:25 PDT 2025

Total time taken to generate the page: 0.00488 seconds