Re: Determining number of decimal positions

2001-03-03 Thread Aaron Ardiri
> >Is there a way I can determine how many decimal > >positions that float value has? yes.. dont use the "float" or "double" type :) store you numbers in integer variables only :) when you want 2 decimal places, divide everything by 100 :) ie: 1.00 is represented as 100 2.00 is

Re: Determining number of decimal positions

2001-03-02 Thread Ben Combee
"John Marshall" <[EMAIL PROTECTED]> wrote in message news:41474@palm-dev-forum... > > Ben Combee <[EMAIL PROTECTED]> wrote: > > Huh? CW honors the \0 escape for both character literals and strings. I > > should know -- I rewrote a lot of that escape parsing code. > [...] > > The problem here is a

Re: Determining number of decimal positions

2001-03-02 Thread John Marshall
Ben Combee <[EMAIL PROTECTED]> wrote: > Huh? CW honors the \0 escape for both character literals and strings. I > should know -- I rewrote a lot of that escape parsing code. [...] > The problem here is actually that the user is specifying a string of 11 > characters -- even with the escaped NULs

My Mistake (was RE: Determining number of decimal positions)

2001-03-02 Thread Richard Burmeister
> From: Ben Combee > > Huh? CW honors the \0 escape for both character literals and strings. I > should know -- I rewrote a lot of that escape parsing code. You might be > confused by the debugger display. When the CW debugger shows a string, it > will show it in escaped C string format, altho

Re: Determining number of decimal positions

2001-03-02 Thread Steve Mann
>Is there a way I can determine how many decimal >positions that float value has? Not as far as I know. Floating point numbers may have infinite precision. For instance, a number like 1.56 may be actually stored as 1.5999. Using simple arithmetic means, you have no way of determining i

RE: Determining number of decimal positions

2001-03-02 Thread Martin Elzen
hi all. A while back I also ran into the problem of how to convert floats to strings and back. I was *astounded* to discover the permitted impreciseness required of float in order to be standards conforming (according to "the C language", 2nd edition). FLT_EPSILON = 1e-5 and DBL_EPSILON =

Re: Determining number of decimal positions

2001-03-01 Thread Ben Combee
"Richard Burmeister" <[EMAIL PROTECTED]> wrote in message news:41361@palm-dev-forum... > > > From: HowY > > > > Char mantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > > Char dispMantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > > > > HowY, > > I don't know about GCC, but with CW the above statements are not cor

RE: Determining number of decimal positions

2001-03-01 Thread Aaron Ardiri
> > Char mantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > > Char dispMantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > > HowY, > > I don't know about GCC, but with CW the above statements are not correct. > You allocate 10 bytes for each string, then assign 21 bytes to each. '\0' > is the char which == 0. "

RE: Determining number of decimal positions

2001-03-01 Thread Richard Burmeister
> From: HowY > > Char mantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > Char dispMantissaStr[10]="\0\0\0\0\0\0\0\0\0\0"; > HowY, I don't know about GCC, but with CW the above statements are not correct. You allocate 10 bytes for each string, then assign 21 bytes to each. '\0' is the char which == 0.

Re: Determining number of decimal positions

2001-03-01 Thread HowY
Hi David I'll chime in here but I'm often on the wrong track compared to the talent you'll find on this list. My float experience is from older os'es ie pre 3.5 using newfloatmgr.h. not knowing what is passed to your .prc i'll toss you this incase it's a FloatType. This function snippit retur

Re: Determining number of decimal positions

2001-03-01 Thread David Leland
Unfortunately, I don't have that luxury. My App is a plug-in to another and I'm being passed a float value so I can't control that side of it. Dave Peter Epstein <[EMAIL PROTECTED]> wrote in message news:41307@palm-dev-forum... > > This may be one of those situations where you should use a fixe

Re: Determining number of decimal positions

2001-03-01 Thread Peter Epstein
This may be one of those situations where you should use a fixed point representation rather than floating point. The problem with floating point binary representations is that they can't exactly represent simply values like 8.95, introducing the possibility of round-off errors. For example, th

RE: Determining number of decimal positions

2001-03-01 Thread Mike Walters
sible to base it on the number itself. Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of David Leland Sent: Thursday, March 01, 2001 11:21 AM To: Palm Developer Forum Subject: Re: Determining number of decimal positions But that's what my prob

Re: Determining number of decimal positions

2001-03-01 Thread David Leland
e force, but it works. > > Mike > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of David > Leland > Sent: Thursday, March 01, 2001 10:00 AM > To: Palm Developer Forum > Subject: Re: Determining number of decimal positi

RE: Determining number of decimal positions

2001-03-01 Thread Mike Walters
ng I know it is kind of brute force, but it works. Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of David Leland Sent: Thursday, March 01, 2001 10:00 AM To: Palm Developer Forum Subject: Re: Determining number of decimal positions I was afraid tha

Re: Determining number of decimal positions

2001-03-01 Thread David Leland
I was afraid that might be the case. So let me ask hypothetically, if the Palm OS supported the "%f" formatting modifier on the StrPrintF function (e.g. returnedString = StrPrintF("%f", floatValue);), what value would be placed into returnedString if the float values were: 12.3450 123.400 1234.5

RE: Determining number of decimal positions

2001-03-01 Thread Mike Walters
By "number of decimal places" do you mean the number before the decimal, the number after, or both? 1) For the number before the decimal place: I don't know of a built-in function, but you could use a small piece of code like the following to count the number of places: int CountDigits (float