I haven't found the built-in float support to suffice for decimal
calculations or comparisons. I have built a couple of different
iterations of myFloat classes. The first represented float values as
Int32 values, e.g. an int value of 123456 with precision of two digits
really means 1234.56. This works fine for small numbers, but doesn't
leave much room for high-precision calculations.
I now use a more sophisticated myFloat class that separates the whole
value, decimal value and sign into separate fields -- i.e.:
class myfloat {
long long wholeVal;
Int32 decVal;
Boolean sign;
};
I've overloaded all of the standard operators, and provided get and set
methods, and I currently use a global constant to define precision. It
took me a while to completely test this class, but I now depend on it
just as much as a string class.
Hope this helps. My baby is crying, so I can't finish my thoughts on
this right now...
Mark Cameron
Techneos Systems
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of John
Gordon
Sent: Wednesday, April 02, 2003 6:41 PM
To: Palm Developer Forum
Subject: Re: Another couple of newbie problems
Hello,
If you haven't already found it, check out the tutorial at
http://tangentsoft.net/palmfaq/arorlticles/tutorial/index.html - read it
all
though, including the debugging section, as there are some "bugs" in the
code
in the earlier section that are "fixed" in the debugging portion of the
tutorial.
> The first one.
>
> I created a database of about 10 records to store some configuration
that I
> don't want to store in the Prefs. Now I can get the info using fields
in my
> config form, but I'm not able to get the info and store it in a char
> variable to use the config info inside the program. How can I read the
> record and store it in a char variable without passing the data
trought a
> field?
Try something like this (from memory, so I hope it's right - somebody'll
correct me if it's not I'm sure ;-):
Char * myCopy;
handle = DmGetRecord(databaseRef, index);
Char *p = (Char *) MemHandleLock(handle);
myCopy = MemPtrNew (StrLen (p) + 1); // null terminated
StrCopy (myCopy, p);
MemPtrUnlock(p);
Could do with some error checking of course, but it shows you the basic
strategy. Remember to free the copy when you're done with it (or when
the
application terminates) using MemPtrFree().
> The second one.
>
> It's a matter of floats, I have to make some calculations about time
and
> cost per minute, but I get a nice 1.1111111e01 kind of result. How can
I
> make it seems like 11.12 in order to be easy of undestand? if you can
help
> me with some examples of how to do this and how to make my
calculations.
Sorry, don't have any info for you on this one... never done anything
with
floating point numbers.
HTH,
John...
=====
Rate Corporate America at http://exec-ratings.bluedonkey.org
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/