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

Converting a char sequence to a float and converting it back

59 views
Skip to first unread message

David

unread,
Oct 17, 2006, 3:50:57 PM10/17/06
to
I created a NUMERIC MAXCHARS 40 UNDERLINED text field for the GUI.
And I figured out how to get the text inside that text field inside the
Palm C Code.
I seem to only be able to extract it as a char sequence even though it
is NUMERIC.
How can i convert my char sequence into float?
static Char bar[80];

And how can i set it back to a char sequence to then apply it back to a
different text field?
The reason I want to do this is to do some math on the number, then
spit it back out in a different text field.
thanks,
David

David

unread,
Oct 17, 2006, 4:03:31 PM10/17/06
to
I searched this forum already,I found articles about this, but none of
them answered my question.
If you can do this,please tell me how.

Baxter

unread,
Oct 17, 2006, 9:55:44 PM10/17/06
to
Your biggest problem is that Palm doesn't do floats very well.

--
---------------------------------------------------------------------
DataGetŽ & PocketLogŽ www.dataget.com
Data Collectors www.baxcode.com
--------------------------------------------------------------------

"David" <williams...@gmail.com> wrote in message
news:1161114656.6...@i3g2000cwc.googlegroups.com...

Ciaran Keating

unread,
Oct 18, 2006, 6:57:36 PM10/18/06
to
On Wed, 18 Oct 2006 05:50:57 +1000, David <williams...@gmail.com>
wrote:

> I created a NUMERIC MAXCHARS 40 UNDERLINED text field for the GUI.
> And I figured out how to get the text inside that text field inside the
> Palm C Code.
> I seem to only be able to extract it as a char sequence even though it
> is NUMERIC.

Hi David,

The NUMERIC parameter means that the text field will accept only the
characters '0' to '9' and the thousands and decimal separator. (Do you
have a copy of the Palm OS Programmer's API Reference?) The OS doesn't do
any string->number conversion for you.


> How can i convert my char sequence into float?
> static Char bar[80];

You'll have to construct the number yourself by parsing the string. Not
quite as trivial as having the OS do it magically for you, but still
trivial nonetheless.


Good luck,
Ciaran

--
Ciaran Keating
Amadán Technologies Pty Ltd

David

unread,
Oct 18, 2006, 8:05:43 PM10/18/06
to
well do you know of a nice little function out there that will convert
it for me?
I dont understand all of the funtimentals of C code to write the
function myself

Ciaran Keating

unread,
Oct 19, 2006, 10:43:39 AM10/19/06
to
On Thu, 19 Oct 2006 10:05:43 +1000, David <williams...@gmail.com>
wrote:

Not trying to be funny or rude or anything, but... if you can do anything
at all in C then you can write this function.

Or maybe you're programming in some other language? In which case, if you
can figure out how to link a C function with an app written in another
language, then you can figure out how to write this function.

In fact, if you can figure out how to install the development tools for
the Palm and get them working, then you've got more than what it takes to
write this function :-)

Go on - give it a try!

Tim Oltrogge

unread,
Oct 19, 2006, 5:14:03 PM10/19/06
to
How about the atof() function?

Then use sprintf() to turn the floating point result back to a string.


Baxter

unread,
Oct 19, 2006, 9:49:54 PM10/19/06
to
Palm does not have a -native- atof() function.

There are a number of ways to go:
- use something like Codewarrior's MSL library
- use the Palm FloatManager (FlpFloat) functions
- write your own routines

or do like a lot of Palm programmers do and use integer math - and fake the
decimal point.

--
---------------------------------------------------------------------
DataGet® & PocketLog® www.dataget.com
Data Collectors www.baxcode.com
--------------------------------------------------------------------

"Tim Oltrogge" <trolt...@verizon.net> wrote in message
news:vURZg.10068$cH6.5572@trnddc07...

Tim Oltrogge

unread,
Oct 20, 2006, 9:53:57 AM10/20/06
to

"Baxter" <lbax02.s...@baxcode.com> wrote in message
news:12jgaq2...@corp.supernews.com...

> Palm does not have a -native- atof() function.

I've only scratched the surface of programming for the Palm. I downloaded
the cygwin tools and compile my programs using the gcc compiler and its
libraries. I'm using atoi() that way and I *assume* atof() is also available
even though it's not mentioned in the Palm reference manual.


Baxter

unread,
Oct 20, 2006, 10:58:04 PM10/20/06
to
Those are NOT -native- Palm functions.

StrAToI() is native to Palm. If you include the Float Manager, there is a
FplAtoF() for FloatTypes - but it is not supported by the PACE 5.0 feature
set.

In any case, floating point on the Palm leaves much to be desired and most
Palm programmers use integer math - simply store the decimal pt as a UInt8
(or uint8_t).

--
---------------------------------------------------------------------
DataGetŽ & PocketLogŽ www.dataget.com
Data Collectors www.baxcode.com
--------------------------------------------------------------------

"Tim Oltrogge" <trolt...@verizon.net> wrote in message

news:Vx4_g.2$rx.1@trnddc04...

0 new messages