Issue 4533: Fixed and truncation/rounding? (cxx_revision) Source: Triodia Technologies Pty Ltd (Mr. Michi Henning, michi(at)triodia.com) Nature: Uncategorized Issue Severity: Summary: Suppose we have: typedef fixed<4,3> FT; interface I { FT op(); }; Suppose the server does: FT I_impl:: op() throw(CORBA::SystemException) { double d = 1.0/3.0; return CORBA::Fixed(d); } There are lots more digits in the return value than what is expected by the client. What should be returned to the client. The rounded value? The truncated value? Similarly, what if we have: double d = 10000000; return CORBA::Fixed(d); Do we return 9.999 to the client (which is the best we can do in this case)? Of course, it is the responsibility of the programmer to make sure that nonsense such as the second case doesn't happen. But the spec has to say what happens if it does happen ;-) Also, the first case will be very common -- what should happen in this case? Resolution: Revised Text: Actions taken: August 23, 2001: received issue Discussion: deferred in June 2011 to the next RTF End of Annotations:===== Date: Fri, 24 Aug 2001 06:57:35 +1000 (EST) From: Michi Henning Reply-To: C++ Revision Task Force To: C++ Revision Task Force cc: issues@omg.org Subject: Fixed and truncation/rounding? Message-ID: Organization: IONA Technologies MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-UIDL: 3/V!!&58e9#0""!DI#!! Suppose we have: typedef fixed<4,3> FT; interface I { FT op(); }; Suppose the server does: FT I_impl:: op() throw(CORBA::SystemException) { double d = 1.0/3.0; return CORBA::Fixed(d); } There are lots more digits in the return value than what is expected by the client. What should be returned to the client. The rounded value? The truncated value? Similarly, what if we have: double d = 10000000; return CORBA::Fixed(d); Do we return 9.999 to the client (which is the best we can do in this case)? Of course, it is the responsibility of the programmer to make sure that nonsense such as the second case doesn't happen. But the spec has to say what happens if it does happen ;-) Also, the first case will be very common -- what should happen in this case? Cheers, Michi. -- Michi Henning +61 7 3324 9633 Chief CORBA Scientist +61 4 1118 2700 (mobile) IONA Technologies +61 7 3324 9799 (fax) Total Business Integration http://www.ooc.com.au/staff/michi Sender: jon@corvette.floorboard.com Message-ID: <3B8576B2.C313D918@floorboard.com> Date: Thu, 23 Aug 2001 14:33:38 -0700 From: Jonathan Biggar X-Mailer: Mozilla 4.77 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: C++ Revision Task Force Subject: Re: Fixed and truncation/rounding? References: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: 8!4!!p^]!!8S(!!fe6!! Michi Henning wrote: > > Suppose we have: > > typedef fixed<4,3> FT; > > interface I { > FT op(); > }; > > Suppose the server does: > > FT > I_impl:: > op() throw(CORBA::SystemException) > { > double d = 1.0/3.0; > return CORBA::Fixed(d); > } > > There are lots more digits in the return value than what is expected by the > client. What should be returned to the client. The rounded value? The > truncated value? Agreed we need to specify this. Do we have any data from other languages with fixed point types as to whether they picked rounding or truncation? > Similarly, what if we have: > > double d = 10000000; > return CORBA::Fixed(d); > > Do we return 9.999 to the client (which is the best we can do in > this case)? > > Of course, it is the responsibility of the programmer to make sure > that > nonsense such as the second case doesn't happen. But the spec has to > say > what happens if it does happen ;-) > > Also, the first case will be very common -- what should happen in > this case? This one is already documented in section 1.11. A DATA_CONVERSION exception is the proper result. -- Jon Biggar Floorboard Software jon@floorboard.com jon@biggar.org Date: Fri, 24 Aug 2001 07:49:55 +1000 (EST) From: Michi Henning To: Jonathan Biggar cc: C++ Revision Task Force Subject: Re: Fixed and truncation/rounding? In-Reply-To: <3B8576B2.C313D918@floorboard.com> Message-ID: Organization: IONA Technologies MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-UIDL: cW9!!N]Pe9Ig\d9kfSd9 On Thu, 23 Aug 2001, Jonathan Biggar wrote: > > There are lots more digits in the return value than what is expected by the > > client. What should be returned to the client. The rounded value? The > > truncated value? > > Agreed we need to specify this. Do we have any data from other > languages with fixed point types as to whether they picked rounding or > truncation? I don't know either. Anyone care to admit to sufficient COBOL knowledge to comment? ;-) I suspect that doing whatever COBOL does would be best. > > Also, the first case will be very common -- what should happen in this case? > > This one is already documented in section 1.11. A DATA_CONVERSION > exception is the proper result. Oops, thanks, you are right! Cheers, Michi. -- Michi Henning +61 7 3324 9633 Chief CORBA Scientist +61 4 1118 2700 (mobile) IONA Technologies +61 7 3324 9799 (fax) Total Business Integration http://www.ooc.com.au/staff/michi