[omniORB] CORBA::Fixed::round() method

Duncan Grisby duncan@grisby.org
Mon Mar 10 12:24:13 2003


On Wednesday 5 March, "Renzo Tomaselli" wrote:

> > round() is used to round an existing fixed number to have a smaller
> > scale. Rounding it to have a larger scale doesn't change it. Why do
> > you think it would?
> 
> my interpretation of specs is that the new fixed must have the requested
> scale, not the smaller.
> >From C++ mapping, (corba 2.3, pag. 20.40):
> "the round and truncate functions convert a fixed value to a new value with
> the specified scale".

You are confusing the value of the fixed point number with its limits.
The limits are an artifact of the type, not of the value. If you want
a scale of 3 decimal places, for example, you must declare a type in
IDL with that scale. Base CORBA::Fixed is, despite its name, not fixed
point at all -- it is decimal floating point.

> Finally I retrieve the right-aligned value through NP_asString() :-( !

NP_asString() truncates trailing zeros, so it won't help you anyway.
The C++ mapping now has a to_string() method that does output trailing
zeros, so you should use that. It's in CVS.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan@grisby.org     --
   -- http://www.grisby.org --