shopsuite-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ShopSuite-dev] [rational type] X/1 --> X


From: Davi Leal
Subject: Re: [ShopSuite-dev] [rational type] X/1 --> X
Date: Sun, 09 Sep 2001 16:29:22 +0100

Tomasz Wegrzanowski wrote:

> > Please, send me it.
>
> Here they are:
>     rx.c        -       posix rx
>     pcre.c      -       perl rx via posix rx api

I attach you the new rational/rational.c and rational/test.sql files. Run 'psql 
shop <
test.sql' and 'cvs diff rational.c'. If you think all is correct I will 
add/commit it
today.

P.D.: Could you design and develop the modification of 'rational/Makefile' so 
as to
add the 'make test' line?. I think you will realize it easier than me. -- If you
agree, please send it so that I can commit it.



> > > But I don't know if it's any useful.
> > > Parser is quite simple, and finding number start and end
> > > is only half of parsing.
> >
> > Well, ... I think the use of a regular expression checker make it easier 
> > and less
> > prone to mistake at some cases. See below:
> >
> >                     "2  "  -->     "2"
> >                  "  23  "  -->    "23"
> >                  " 4/7  "  -->   "4/7"
> >                    "sk2 "  -->   "0/0"
> >                 " 3/4 A"  --> "0/0"
> >                 " 3/4 A "  --> "0/0"
> >
> >                 " 3/4 8"  --> "0/0"
> >                 " 3/48  "  --> "1/16"
> >                 Note that the initial and final blanks are
> >                 stripped but not the middle ones.
>
> That was "by design". Of course it's easy to change `design'.

I have thought the design is right. What do you think?.

X bitmap

-- rational_in() tests

select rational('1') AS one;
select rational('-1') AS minus_one;

select rational('0/0') AS undef;
select rational('0/1') AS zero;
select rational('0/2') AS zero;

select rational('1/0') AS undef;
select rational('9/0') AS undef;

select rational('1/2') AS half;
select rational('4/6') AS two_third;

select rational('-0/0') AS undef;
select rational('-0/1') AS zero;
select rational('-0/2') AS zero;

select rational('-1/0') AS undef;
select rational('-9/0') AS undef;

select rational('-1/2') AS minus_half;
select rational('-4/6') AS minus_two_third;

select rational(' 1 ') AS one;
select rational(' -1 ') AS minus_one;
select rational(' 9/0 ') AS undef;
select rational(' 1/2 ') AS half;
select rational(' -4/6 ') AS minus_two_third;

select rational(' 1') AS one;
select rational(' -1') AS minus_one;
select rational(' 9/0') AS undef;
select rational(' 1/2') AS half;
select rational(' -4/6') AS minus_two_third;

select rational('1 ') AS one;
select rational('-1 ') AS minus_one;
select rational('9/0 ') AS undef;
select rational('1/2 ') AS half;
select rational('-4/6 ') AS minus_two_third;


-- arith tests

select rational('0/1') + rational('1/2') AS half;
select rational('1/2') + rational('1/2') AS one;
select rational('1/2') + rational('-1/2') AS zero;
select rational('-1/2') + rational('-1/2') AS minus_one;

select rational('1/2') + rational('1/0') AS undef;
select rational('0/2') + rational('0/0') AS undef;
select rational('0/2') + rational('1/0') AS undef;
select rational('0/2') + rational('0/3') AS zero;

select rational('1/2') - rational('-1/2') AS one;
select rational('1/2') - rational('1/2') AS zero;
select rational('2/1') - rational('-1/1') AS three;
select rational('2/1') - rational('1/1') AS one;

select rational('2/1') * rational('1/2') AS one;
select rational('-1/2') * rational('-1/2') AS one_fourth;
select rational('1/2') * rational('-1/2') AS minus_one_fourth;
select rational('-1/2') * rational('1/2') AS minus_one_fourth;

select rational('2/3') / rational('2/3') AS one;
select rational('2/3') / rational('-3/2') AS minus_four_nineths;
select rational('-2/3') / rational('3/2') AS minus_four_nineths;


-- comparisions tests

select rational('0/1') = rational('1/2') AS false;
select rational('-1/2') > rational('1/2') AS false;
select rational('0/0') != rational('0/1') AS true;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]