Reply to message «Re: rounding numbers», 
sent 10:25:48 14 January 2011, Friday
by rameo:

> I tried to put another substitute command before str2float but this
> doesn't work..
> Before printf command doesn't work either. It print the whole text.
> Well, no matter.
What do you mean when use `before'? With nested function calls like f(g(h(x))) 
functions are executed in reversed order: first h, then g, then f. It is 
obvious, but I used to make mistakes by putting substitute in a wrong place. In 
either case, you should have put new substitute `before' old substitute (so 
that 
it will process submatch first), not `before' str2float.

    
\=printf('%.0f',str2float(substitute(substitute(submatch(0),'\.','','g'),',','.','')))
works for me (though it does not retain a dot). If you want to output with a 
dot, either add another substitute after printf, or use other scripting 
language 
that has better locale support.

Original message:
> On Jan 13, 9:13 pm, ZyX <[email protected]> wrote:
> > Reply to message «Re: rounding numbers»,
> > sent 21:17:29 13 January 2011, Thursday
> > 
> > by rameo:
> > > That's what I thought also but it will replace all dots in ",", also
> > > the thousand seperators and other dots
> > > No way to re-capture the numbers i.m.o.
> > 
> > No, it won't. First purge dots, and only then replace `,'.
> 
> I tried to put another substitute command before str2float but this
> doesn't work..
> Before printf command doesn't work either. It print the whole text.
> Well, no matter.
> 
> However, thanks for your help.

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to