[system] / trunk / pg / lib / Parser / Number.pm Repository: Repository Listing bbplugincoursesdistsnplrochestersystemwww

# Diff of /trunk/pg/lib/Parser/Number.pm

Revision 2624 Revision 2625
15 \$value = \$value + 0; # format the value as a number 15 \$value = \$value + 0; # format the value as a number
16 \$num = bless { 16 \$num = bless {
17 value => \$value, type => \$Value::Type{number}, isConstant => 1, 17 value => \$value, type => \$Value::Type{number}, isConstant => 1,
18 ref => \$ref, equation => \$equation, 18 ref => \$ref, equation => \$equation,
19 }, \$class; 19 }, \$class;
20 my \$x = Value::Real->make(\$value);
20 \$num->{isOne} = 1 if (\$value == 1); 21 \$num->{isOne} = 1 if \$x eq 1;
21 \$num->{isZero} = 1 if (\$value == 0); 22 \$num->{isZero} = 1 if \$x == 0;
22 return \$num; 23 return \$num;
23} 24}
24 25
25# 26#
26# We know the answers to these, so no need to compute them 27# We know the answers to these, so no need to compute them
41sub reduce { 42sub reduce {
42 my \$self = shift; 43 my \$self = shift;
43 if (\$self->{value} < 0) { 44 if (\$self->{value} < 0) {
44 \$self->{value} = -(\$self->{value}); 45 \$self->{value} = -(\$self->{value});
45 \$self = Parser::UOP::Neg(\$self); 46 \$self = Parser::UOP::Neg(\$self);
46 \$self->{op}{isOne} = 1 if \$self->{op}{value} == 1; 47 \$self->{op}{isOne} = 1 if Value::Real->make(\$self->{op}{value}) eq 1;
47 } 48 }
48 return \$self; 49 return \$self;
49} 50}
50 51
51# 52#

Legend:
 Removed from v.2624 changed lines Added in v.2625