Format '-(35)9.9(2)'

Tools & Utilities
Highlighted

Format '-(35)9.9(2)'

Hi There,

 

Want to understand how this formula exactly works 

 

Trim(value(FORMAT '-(35)9.9(2)'))

 

when value is 0.1950000, the output is 0.20

when value is 0.5850000, the output is 0.58

 

can someone help me understand this please 

 

Thanks

Nikhith 


Accepted Solutions
Teradata Employee

Re: Format '-(35)9.9(2)'

Hi Nikhith,

 

Yes, this one is not "natural" but it's fully documented :

Results of a FORMAT Phrase Defining Too Few Positions

 

Extract :

 

Rounding is based on “Round to the Nearest” mode, as illustrated by the following process.

  1. Let B represent the actual result.
  2. Let A and C represent the nearest bracketing values that can be represented, such that A < B < C.
  3. The determination as to whether A or C is the represented result is made as follows
    1. When possible, the result is the value nearest to B.
    2. If A and C are equidistant (for example, the fractional part is exactly .5), the result is the even number.
1 ACCEPTED SOLUTION
3 REPLIES 3
Teradata Employee

Re: Format '-(35)9.9(2)'

Hi Nikhith,

 

Yes, this one is not "natural" but it's fully documented :

Results of a FORMAT Phrase Defining Too Few Positions

 

Extract :

 

Rounding is based on “Round to the Nearest” mode, as illustrated by the following process.

  1. Let B represent the actual result.
  2. Let A and C represent the nearest bracketing values that can be represented, such that A < B < C.
  3. The determination as to whether A or C is the represented result is made as follows
    1. When possible, the result is the value nearest to B.
    2. If A and C are equidistant (for example, the fractional part is exactly .5), the result is the even number.

Re: Format '-(35)9.9(2)'

 

Thanks Waldar, 

 

Thanks for listing down the points, I know exactly understand what's happening. My brains were literally going off, for this one :)

 

 

Regards

Nikhith 

Teradata Employee

Re: Format '-(35)9.9(2)'

Just for completeness:

Round Half Even (as described) is the Teradata default method for rounding FLOAT and DECIMAL.

But by default, NUMBER uses the Round Half Away From Zero method (also known as "commercial rounding") instead.

And there are dbscontrol options to use Round Half Away From Zero for DECIMAL, or to use Round Half Even for both DECIMAL and NUMBER .