Re: Round...

2004-02-17 Thread Robert Scott
On Tue, 17 Feb 2004 09:25:49 -0500, "Dave Lippincott"
<[EMAIL PROTECTED]> wrote:

>If you know the number of decimal places you require you can round the
>number yourself.
>i.e. if you require 2 places use:
>RoundedNo = 3,213,123.4590 + 0.005
>you will get 3,213,123.46 (ignoring the decimals places beyond the 2nd)

Caution:  (int)(x + 0.5) only rounds properly if x is positive.  For
negative values of x, use (int)(x - 0.5)


Robert Scott, Ypsilanti, MI
(reply through this forum, not by e-mailing me directly)

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Re: Round...

2004-02-17 Thread Dave Lippincott
If you know the number of decimal places you require you can round the
number yourself.
i.e. if you require 2 places use:
RoundedNo = 3,213,123.4590 + 0.005
you will get 3,213,123.46 (ignoring the decimals places beyond the 2nd)
If you are working with money, you should stick with integers as you will
loose precision (and change).   Either scale a long or use two integers.

- Original Message - 
From: "Mihai Ciornei" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Tuesday, February 17, 2004 2:39 AM
Subject: Round...


There is any way(function) in CodeWarrior 9.2 to round a
double?
Something like "round(3.213.123,4598 ; precision) =
3.213.123,46..."  without using strings.

I tried:

#include 
double round(double)

but no use.

Thanks for any help I get.

Regards,

Ciornei Mihai - Bogdan,
Analyst programmer
TRANSART ltd (www.transart.ro)



-- 
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/


Re: Round...

2004-02-17 Thread Ben Combee
At 01:39 AM 2/17/2004, you wrote:
There is any way(function) in CodeWarrior 9.2 to round a
double?
Something like  "round(3.213.123,4598 ; precision) =
3.213.123,46..."  without using strings.
I tried:

#include 
    double round(double)
but no use.
Sounds like you need MathLib.  See the CW project wizard -- its a shared 
library that implements floating point math functions.  More docs in CW for 
Palm OS Support/(Other SDKs)/MathLib.



--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Round...

2004-02-16 Thread Mihai Ciornei
There is any way(function) in CodeWarrior 9.2 to round a
double?
Something like  "round(3.213.123,4598 ; precision) =
3.213.123,46..."  without using strings.

I tried:

#include 
    double round(double)

but no use.

Thanks for any help I get.

Regards,  

Ciornei Mihai - Bogdan,
Analyst programmer
TRANSART ltd (www.transart.ro)



--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/


Round floating point

2000-10-30 Thread Mbarrion

Hello,

Could you help me, please.

Maybe, Du you have some code to round  floating numbers

Thanks,

Regards,
Marco

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/



Round point float

2000-10-30 Thread Mbarrion

Hello,

Could you help me, please.

Maybe, Du you have some code to round  floating numbers

Thanks,

Regards,
Marco

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/



RE: How do I round a float to 2 decimal places????

2000-03-13 Thread Fitzpatrick, Joe

You're right - more precise.

Good catch!
-jjf

-Original Message-
From: Ron Nicholson [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 13, 2000 11:18 PM
To: Palm Developer Forum
Subject: Re: How do I round a float to 2 decimal places


One might also consider adding 0.5 after scaling, as 0.005 does not have
an exact IEEE binary floating point representation.


IMHO. YMMV.
--
Ron Nicholson
HotPaw
http://www.hotpaw.com/rhn/hotpaw/

(In some other forums, one might suspect that a high school student
is asking questions like this in order to get answers to his or her
homework assignment...)

--
Fitzpatrick, Joe  writes:
>Wouldn't it be:
>
>Add .005, then... ?
>
>-Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>
>Sent: Monday, March 13, 2000 2:44 PM
>To: Palm Developer Forum
>Subject: Re: How do I round a float to 2 decimal places
>
>
>
>
>Multiply by 100, print as an integer, decorate as necessary.
>
>-- Keith
>
>
>
>
>
>
>Steve Sabram <[EMAIL PROTECTED]> on 03/12/2000 09:03:55 AM
>
>Please respond to "Palm Developer Forum"
><[EMAIL PROTECTED]>
>
>Sent by:  Steve Sabram <[EMAIL PROTECTED]>
>
>
>To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
>cc:(Keith Rollin/HQ/3Com)
>Subject:  Re: How do I round a float to 2 decimal places
>
>
>
>
>Don't be.  There is no facility for this on the OS.  You will need to
>write your
>own rounding routine.
>
>Steve
>
>Palm Programming wrote:
>
>> I feel stupid asking this, but how to I take a float that I have
>calculated
>and format it so that
>> it is rounded to 2 decimal places when I turn it into a string???
>Help!
>>
>> Steve Weintraut
>> [EMAIL PROTECTED]

-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html



Re: How do I round a float to 2 decimal places????

2000-03-13 Thread Ron Nicholson

One might also consider adding 0.5 after scaling, as 0.005 does not have
an exact IEEE binary floating point representation.


IMHO. YMMV.
--
Ron Nicholson
HotPaw
http://www.hotpaw.com/rhn/hotpaw/

(In some other forums, one might suspect that a high school student
is asking questions like this in order to get answers to his or her
homework assignment...)

--
Fitzpatrick, Joe  writes:
>Wouldn't it be:
>
>Add .005, then... ?
>
>-Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>
>Sent: Monday, March 13, 2000 2:44 PM
>To: Palm Developer Forum
>Subject: Re: How do I round a float to 2 decimal places
>
>
>
>
>Multiply by 100, print as an integer, decorate as necessary.
>
>-- Keith
>
>
>
>
>
>
>Steve Sabram <[EMAIL PROTECTED]> on 03/12/2000 09:03:55 AM
>
>Please respond to "Palm Developer Forum"
><[EMAIL PROTECTED]>
>
>Sent by:  Steve Sabram <[EMAIL PROTECTED]>
>
>
>To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
>cc:(Keith Rollin/HQ/3Com)
>Subject:  Re: How do I round a float to 2 decimal places
>
>
>
>
>Don't be.  There is no facility for this on the OS.  You will need to
>write your
>own rounding routine.
>
>Steve
>
>Palm Programming wrote:
>
>> I feel stupid asking this, but how to I take a float that I have
>calculated
>and format it so that
>> it is rounded to 2 decimal places when I turn it into a string???
>Help!
>>
>> Steve Weintraut
>> [EMAIL PROTECTED]

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html



RE: How do I round a float to 2 decimal places????

2000-03-13 Thread Fitzpatrick, Joe

Wouldn't it be:

Add .005, then... ?

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 13, 2000 2:44 PM
To: Palm Developer Forum
Subject: Re: How do I round a float to 2 decimal places




Multiply by 100, print as an integer, decorate as necessary.

-- Keith






Steve Sabram <[EMAIL PROTECTED]> on 03/12/2000 09:03:55 AM

Please respond to "Palm Developer Forum"
<[EMAIL PROTECTED]>

Sent by:  Steve Sabram <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (Keith Rollin/HQ/3Com)
Subject:  Re: How do I round a float to 2 decimal places




Don't be.  There is no facility for this on the OS.  You will need to
write your
own rounding routine.

Steve

Palm Programming wrote:

> I feel stupid asking this, but how to I take a float that I have
calculated
and format it so that
> it is rounded to 2 decimal places when I turn it into a string???
Help!
>
> Steve Weintraut
> [EMAIL PROTECTED]
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please
see http://www.palm.com/devzone/mailinglists.html


--
For information on using the Palm Developer Forums, or to unsubscribe,
please
see http://www.palm.com/devzone/mailinglists.html






-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html



Re: How do I round a float to 2 decimal places????

2000-03-13 Thread krollin



Multiply by 100, print as an integer, decorate as necessary.

-- Keith






Steve Sabram <[EMAIL PROTECTED]> on 03/12/2000 09:03:55 AM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

Sent by:  Steve Sabram <[EMAIL PROTECTED]>


To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:(Keith Rollin/HQ/3Com)
Subject:  Re: How do I round a float to 2 decimal places




Don't be.  There is no facility for this on the OS.  You will need to write your
own rounding routine.

Steve

Palm Programming wrote:

> I feel stupid asking this, but how to I take a float that I have calculated
and format it so that
> it is rounded to 2 decimal places when I turn it into a string??? Help!
>
> Steve Weintraut
> [EMAIL PROTECTED]
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palm.com/devzone/mailinglists.html


--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palm.com/devzone/mailinglists.html






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html



Re: How do I round a float to 2 decimal places????

2000-03-12 Thread Steve Sabram

Don't be.  There is no facility for this on the OS.  You will need to write your own 
rounding routine.

Steve

Palm Programming wrote:

> I feel stupid asking this, but how to I take a float that I have calculated and 
>format it so that
> it is rounded to 2 decimal places when I turn it into a string??? Help!
>
> Steve Weintraut
> [EMAIL PROTECTED]
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please see 
>http://www.palm.com/devzone/mailinglists.html


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html



How do I round a float to 2 decimal places????

2000-03-11 Thread Palm Programming

I feel stupid asking this, but how to I take a float that I have calculated and format 
it so that
it is rounded to 2 decimal places when I turn it into a string??? Help!

Steve Weintraut
[EMAIL PROTECTED]


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html