Math problems?

Jan Schenkel janschenkel at yahoo.com
Fri May 19 15:34:49 EDT 2006


--- Mark Swindell <mdswindell at cruzio.com> wrote:
> > put 10.27 into tNumber
> > put the trunc of tNumber into tInteger
> > put tNumber - tInteger into tDecimal
> > put 100 * tDecimal into tNew Decimal
> > put  tNewDecimal
> > -- put the trunc of tNewDecimal
> >
> 
> = 27
> 
> 
> On May 19, 2006, at 12:04 PM, Peter T. Evensen
> wrote:
> 
> > put 10.27 into tNumber
> > put the trunc of tNumber into tInteger
> > put tNumber - tInteger into tDecimal
> > put 100 * tDecimal into tNew Decimal
> > -- put  tNewDecimal
> > put the trunc of tNewDecimal
> 
> = 26
> 

Hi Peter and Mark,

I'm guessing that 27 cannot be represented exactly in
binary format, so the 27 you see when you "put
tNewDecimal" is due to Revolution trying to round it
to the closest number, but the 26 the see when you
"put the trunc of tNewDecimal" is because internally
it's something like 26.99999 - and chopping off the
decimals there will give you 26.

You could always add a really small number to 'flip it
over' to the higher number for this sort of occasion:
##
put 100 * tDecimal into tNew Decimal
add 0.000001 to tNewDecimal
put the trunc of tNewDecimal
##

Hope this helped,

Jan Schenkel.

Quartam Reports for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the use-livecode mailing list