GiNaC::parser parses "3^+2+1" in the wrong order
20 Feb
2023
20 Feb
'23
1:21 p.m.
Hi, all. When parsing expressions with sign in the exponent, GiNaC's parses confuses the priorities somehow. Here are some examples: 3^2+1 is parsed as (3^2)+1, which is correct; 3^+2+1 is parsed as 3^(+2+1), which is wrong; 3^-2+1 is parsed as 3^(-2+1), which is wrong; 3^+2/3 is parsed as 3^(+2/3), which is wrong; etc. Here's a test case, it will print 27, not the correct 10: #include <ginac/ginac.h> #include <ginac/parser.h> #include <iostream> #include <sstream> #include <string> int main() { std::string input = "3^+2+1"; std::istringstream instream(input); GiNaC::parser reader; GiNaC::ex expr = reader(instream); std::cout << input << " = " << expr << "\n"; }
860
Age (days ago)
860
Last active (days ago)
0 comments
1 participants
participants (1)
-
Vitaly Magerya