Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Precision of msscanf?

8 views
Skip to first unread message

Tim Wescott

unread,
Dec 22, 2009, 1:09:48 PM12/22/09
to
I am converting a string with numbers that have formats like

mystring = ['+03119.358368 +00059.509320'; '+03119.359514 +00059.360184'];

I'm using

mynumbers = msscanf(-1, '%f %f', mystring);

But the results that I'm getting are truncated, to what appears to be
single-precision floating point. Is this an inescapable deficit with
msscanf? If not, how do I coerce msscanf into doing this with full
precision? If it is, is there an alternate built-in function that will
do this, or do I need to come up with some work around?

Thanks.

--
www.wescottdesign.com

Tim Wescott

unread,
Dec 22, 2009, 1:38:53 PM12/22/09
to

Answered my own question:

mynumbers = msscanf(-1, '%lf %lf', mystring);

note the 'lf' instead of 'f'.

THAT'S IT?????

Since you're plugging things into doubles anyway, you couldn't just make
that DEFAULT?????

Oh well, onward and upward, I guess.

--
www.wescottdesign.com

Tim Wescott

unread,
Dec 22, 2009, 1:49:03 PM12/22/09
to

Oops. That's not it -- it was leftovers from a previous attempt,
apparently.

So, is there a way?

--
www.wescottdesign.com

Tim Wescott

unread,
Dec 22, 2009, 2:33:39 PM12/22/09
to

Newsgroups are such a nice forum for publicly embarrassing oneself.

'%lg'. _Not_ '%f', '%g', or '%lf'.

Oh well, at least now my app works better...

--
www.wescottdesign.com

Francois Vogel

unread,
Dec 22, 2009, 2:42:45 PM12/22/09
to
Tim Wescott said on 22/12/2009 20:33:

> Newsgroups are such a nice forum for publicly embarrassing oneself.
>
> '%lg'. _Not_ '%f', '%g', or '%lf'.

Also:

mynumbers = msscanf(-1, mystring, '%lg %lg');

and not:

mynumbers = msscanf(-1, '%lg %lg', mystring);

;-)

> Oh well, at least now my app works better...

Congratulations.

Francois

Jean-Pierre Vial

unread,
Dec 22, 2009, 4:17:28 PM12/22/09
to
Le 22/12/2009 19:09, Tim Wescott a écrit :
> mynumbers = msscanf(-1, '%f %f', mystring);
use %lg instead of %f (and check the order of the parameters for msscanf)
0 new messages