@@ -33,40 +33,25 @@ public static BslValue Add(BslValue left, BslValue right)
3333
3434 var dLeft = ( decimal ) left ;
3535 var dRight = ( decimal ) right ;
36- return BslNumericValue . Create ( dLeft + dRight ) ;
36+ return BslNumericValue . Create ( dLeft + dRight ) ; // or throw ConvertToNumberException();
3737 }
3838
3939 public static BslValue Subtract ( BslValue left , BslValue right )
4040 {
4141 if ( left is BslNumericValue num )
42+ return BslNumericValue . Create ( num - ( decimal ) right ) ;
43+
44+ if ( left is BslDateValue date )
4245 {
43- var result = num - ( decimal ) right ;
44- return BslNumericValue . Create ( result ) ;
45- }
46- else if ( left is BslDateValue date )
47- {
48- switch ( right )
49- {
50- case BslNumericValue numRight :
51- {
52- var result = date - numRight ;
53- return BslDateValue . Create ( result ) ;
54- }
55- case BslDateValue dateRight :
56- {
57- var result = date - dateRight ;
58- return BslNumericValue . Create ( result ) ;
59- }
60- }
61- }
62- else
63- {
64- var dLeft = ( decimal ) left ;
65- var dRight = ( decimal ) right ;
66- return BslNumericValue . Create ( dLeft - dRight ) ;
46+ if ( right is BslDateValue dateRight )
47+ return BslNumericValue . Create ( date - dateRight ) ;
48+
49+ return BslDateValue . Create ( date - ( decimal ) right ) ;
6750 }
6851
69- throw BslExceptions . ConvertToNumberException ( ) ;
52+ var dLeft = ( decimal ) left ;
53+ var dRight = ( decimal ) right ;
54+ return BslNumericValue . Create ( dLeft - dRight ) ; // or throw ConvertToNumberException();
7055 }
7156
7257 public static bool ToBoolean ( BslValue value )
0 commit comments