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

multiplication bug in director 9999*999999

0 views
Skip to first unread message

YM

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to
I am programming catalog of prodacts- some of them cost 9999.99 so in my
field i
put 7 chars option for the price.
I put 4 chars for units number so- when some one will do 9999*999999 the
resolt is in correct (someTimes it is minus!!!)
try to do this in the msg "put 999999*9999" and you will see what i am
talking about.
if some budy knows the answer to this bug please contact me in
u...@poenta.co.il
thanks udi.

Andrew Morton

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to
(I needed a couple more 9's to get the error.)
Not a bug so much as a failure to trap overflow when multiplying signed 32-bit integers.
Try put the maxInteger +1 for a similar result.
If you put 99999.0*9999999 it gives the correct result as you've forced it to use
floating-point numbers.

Andrew Morton

Vince Brokop

unread,
Nov 8, 2000, 3:00:00 AM11/8/00
to YM
i'm using director 8... this is really odd! i can get up to 99999*9999 and
still get the correct answer... add one more 9, and while i do get a
positive number, it is incorrect according to my handy calculator here, AND
windows calculator.
i don't know what to tell you... you're going to have to find a workaround
of some sort.

Luke Wigley

unread,
Nov 9, 2000, 12:09:33 AM11/9/00
to
in article 3A0A19BC...@fulltiltmedia.com, Vince Brokop at
vbr...@fulltiltmedia.com wrote on 9/11/00 2:27 PM:

> i'm using director 8... this is really odd! i can get up to 99999*9999 and
> still get the correct answer... add one more 9, and while i do get a
> positive number, it is incorrect according to my handy calculator here, AND
> windows calculator.
> i don't know what to tell you... you're going to have to find a workaround
> of some sort.

There is a maximum integer that is supported by the system. In lingo, you
can test what the biggest integer is with the 'maxInteger' system property.
Eg.

-- Welcome to Director --
put the maxInteger
-- 2147483647

In 32-bit systems, this number is 2 to the power of 31 minus 1 (its 2 to the
power of 31, not 32, because the extra bit is used to sign the integer as
either positive or negative).

Signed-32bit integers are represented with four bytes. This makes them very
quick to process. If you are working with big numbers, then use floats which
can be bigger than 4 bytes (though processing floating numbers is inherently
slower than processing integers).

Incidently, if you type this into the message window

put power(2, 31)-1
-- 2147483647.0000

You will notice that the power function seems to automatically type-change
integers into floats, probably because the risk of creating big numbers.
However, if you multiply two integers -- then Director will try and keep
them as integers, even if the result is too big.

Luke
--

__________________________________________________________________________
Mecca Medialight Pty Ltd

Mecca Medialight: Medialight Sound Studio:
111 Moor Street 1 Bakehouse Lane
Fitzroy, Vic. 3065 North Fitzroy, Vic. 3068
Tel +613 9416 2033 Tel +613 9416 2033
Fax +613 9416 2055 Fax +613 9416 2055

http://www.medialight.com.au
__________________________________________________________________________


0 new messages