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

A strange answer ...

2 views
Skip to first unread message

DiPauli

unread,
Sep 5, 2008, 6:49:05 AM9/5/08
to
Integer li_Response, li_abc

li_abc = 3
li_Response = 31 * (li_abc/4)

Why the answer is 23? It should not be 0? (31 * 0 = 0)

Renato Di Pauli


Chris Pollach

unread,
Sep 5, 2008, 7:23:06 AM9/5/08
to
Hi Renato ;

Hmmmm .... I get 23 here in PB 11.2 and 11.5?

--
Regards ... Chris
ISUG - NA RUG Director
http://chrispollach.pbdjmagazine.com


"DiPauli" <r.di...@alice.it> wrote in message
news:48c10ea1@forums-1-dub...

Jerry Siegel [TeamSybase]

unread,
Sep 5, 2008, 8:54:09 AM9/5/08
to
See the Help topic "Datatype promotion when evaluating numeric expressions"
Poor old integer is on the bottom of the list.
So it did 31*.75 = 23.25, truncated to 23 when cast to integer.

"DiPauli" <r.di...@alice.it> wrote in message
news:48c10ea1@forums-1-dub...

Bruce Armstrong [TeamSybase]

unread,
Sep 5, 2008, 9:00:22 AM9/5/08
to

The division operation will produce a double value rather than a long.
So you'll end up with 0.75 there. The result will get converted back
to a long after the multipication operation when it's assigned to a
long variable.

See the section of the help entitled "Datatype promotion when
evaluating numeric expressions"

DiPauli

unread,
Sep 5, 2008, 9:12:13 AM9/5/08
to
OK,
is now clear.
Thanks

"DiPauli" <r.di...@alice.it> ha scritto nel messaggio
news:48c10ea1@forums-1-dub...

KL

unread,
Sep 5, 2008, 12:59:10 PM9/5/08
to
or...

(li_abc/4) = 0.75
integer((li_abc/4)) = 0

HTH KL

0 new messages