RE: Definition of integer division

From: Muranyi, Arpad <arpad.muranyi_at_.....>
Date: Wed Dec 14 2005 - 09:31:57 PST
Geoffrey,

Thank you and all others who replied to my question. 
I think I understand what makes an integer division
now.

My confusion came from not knowing whether integer
division was caused by having two integer operands
or whether it was the "/" operator itself doing it.
So I started to look for another operator that would
be a "real division" operator, but didn't find one.
Then I searched for "integer division" in the LRM to
see what its definition was, but didn't find anything.

Yes, I saw the things about automatic type conversions,
but there are two kinds described in the LRM which didn't
help to clarify my confusion.  Section 4.1.1.1 says:

"Real numbers are converted to integers by rounding the real number to the nearest
integer, rather than by truncating it. Implicit conversion takes place when a real number
is assigned to an integer. The ties are rounded away from zero (0)."

If integer division was implemented based on the operator
"/" then my thinking would say, aha, this operator takes
two integer operands, so if I put a real number in either
place, it will convert it to an integer before executing the
integer division.  Of course since I didn't find any other
divider operators, I felt that this would probably be not
the case, but I wasn't sure whether I just missed something
or it really didn't exist.

Yes, section 4.1.1.2 talks about converting an integer operand
to real if the other operand is real.  However, from the second
example b=1/2 it is not clear that this is integer division
BECAUSE both operands are integers, and not because of the "/"
operator.

Sorry for the lengthy message, I just wanted to give all of you
a picture of what can go through someone's mind if they learn
the language with a fresh start...

I think either a definition for what "integer division" is,
or a clarification in this example would be useful to have
in the LRM.

Thanks,

Arpad
=============================================================

-----Original Message-----
From: owner-verilog-ams@eda.org [mailto:owner-verilog-ams@eda.org] On Behalf Of Geoffrey.Coram
Sent: Wednesday, December 14, 2005 6:12 AM
To: verilog-ams@eda.org
Subject: Re: Definition of integer division

Also see 4.1.1.2, Arithmetic conversion, which says that
if either operand is real, the other operand is converted
to real, thus 2) and 3) are performed as real division.

But you must have read that section, since "integer
division" appears twice therein.  Are you concerned that
the LRM does not specify that "integer division" means
truncation as Shalom pointed out?

-Geoffrey


"Muranyi, Arpad" wrote:
> 
> I am trying to figure out from the v2.2 LRM what the
> definition of "integer division" is.  This appears
> three times in the LRM, but it really doesn't say what
> it is.
> 
> Which one of these is/are considered integer division:
> 
> 1)   integer / integer
> 2)   real / integer
> 3)   integer / real
> 
> Thanks,
> 
> Arpad
> =====================================================
Received on Wed Dec 14 09:32:13 2005

This archive was generated by hypermail 2.1.8 : Wed Dec 14 2005 - 09:32:30 PST