Page 1 of 1

Update oddty

Posted: Thu Oct 17, 2013 12:57 am
by Chris Walton
The following are all valid tuples of Month_days_lookup:

Code: Select all

Month_days_lookup := RELATION {
  TUPLE { sort sort# ( 00 ), name ID ( "" ), days N31Z ( 0 ), prior_days N366Z ( 0 ) },
  TUPLE { sort sort# ( 01 ), name ID ( "January" ), days N31Z ( 31 ), prior_days N366Z ( 0 ) },
  TUPLE { sort sort# ( 02 ), name ID ( "February" ), days N31Z ( 28 ), prior_days N366Z ( 31 ) },
  TUPLE { sort sort# ( 03 ), name ID ( "March" ), days N31Z ( 31 ), prior_days N366Z ( 60 ) },
  TUPLE { sort sort# ( 04 ), name ID ( "April" ), days N31Z ( 30 ), prior_days N366Z ( 91 )},
  TUPLE { sort sort# ( 05 ), name ID ( "May" ), days N31Z ( 31 ), prior_days N366Z ( 121 ) },
  TUPLE { sort sort# ( 06 ), name ID ( "June" ), days N31Z ( 30 ), prior_days N366Z ( 152 ) },
  TUPLE { sort sort# ( 07 ), name ID ( "July" ), days N31Z ( 31 ), prior_days N366Z ( 182 ) },
  TUPLE { sort sort# ( 8 ), name ID ( "August" ), days N31Z ( 31 ), prior_days N366Z ( 213 ) },
  TUPLE { sort sort# ( 9 ), name ID ( "September" ), days N31Z ( 30 ), prior_days N366Z ( 244 ) } };
But

Code: Select all

Month_days_lookup := RELATION {
  TUPLE { sort sort# ( 08 ), name ID ( "August" ), days N31Z ( 31 ), prior_days N366Z ( 213 ) } };
Month_days_lookup := RELATION {
  TUPLE { sort sort# ( 09 ), name ID ( "September" ), days N31Z ( 30 ), prior_days N366Z ( 244 ) } };
give respective errors of:

Code: Select all

ERROR: Encountered "8" at line 2, column 25.
ERROR: Encountered "9" at line 2, column 25.
I have checked for the possibility that I typed 'O' rather than '0' (oh rather than zero), but this not the position. Nonetheless it is acting as though entry has been of octal values. The definition of sort# is:

Code: Select all

TYPE sort# POSSREP { VALUE INTEGER CONSTRAINT VALUE >= 0 };

Re: Update oddty

Posted: Sat Oct 19, 2013 7:50 am
by Dave
Prefixing an integer literal with 0 is treated as octal. It's not a bug. :)

Re: Update oddty

Posted: Sat Oct 19, 2013 3:56 pm
by Chris Walton
Is there then a way of storing a normal integer with a fixed number of significant places?

Re: Update oddty

Posted: Sat Oct 19, 2013 4:32 pm
by Dave
A fixed-precision number is not a built-in type, and because non-floating numeric literals are recognised by the parser as INTEGER, you'll need to create a new type.