add gcd if all int

This commit is contained in:
hugogogo
2026-05-14 12:31:32 +02:00
parent d770d7fc87
commit bbe0d65b1f
7 changed files with 120 additions and 95 deletions

View File

@@ -2,7 +2,6 @@
## todo
- create tester
- if no "=" sign return error
- doing gcd for int values, and not for double values
- double is nearly_equal_0
@@ -20,63 +19,6 @@ this project uses submodules (maybe recursively), so either :
- `git clone --recurse-submodules <repo-url>`
- or, after cloning : `git submodule update --init --recursive`
## steps
1. lexer
-> tokens types :
- TOKEN_VARIABLE // x, y, etc.
- TOKEN_NUMBER_INT // int
- TOKEN_NUMBER_DOUBLE // double
- TOKEN_POWER // ^ or **
- TOKEN_SIGN_PLUS // +
- TOKEN_SIGN_MINUS // -
- TOKEN_FACTOR_MULT // *
- TOKEN_FACTOR_DIV // / or :
- TOKEN_EQUAL // =
- END // null
2. parser
-> terms :
- POSITION // left or righ from =
- SIGN // + or -
- COEFFICIENT // double
- EXPONENT // double
3. reduce
-> polynom :
- sign
- coefficient
- exponent
4. print reduced form
-> print reduced form
-> if degree 1 :
- if c = 0 -> print "any real is a solution"
- if c != 0 -> print "no solution"
-> if degree 2 :
- print degree
-> if degree 3 :
- print degree
5. solve
-> degree 1 :
-> ax + b = 0 <=> ax = -b <=> x = -b / a
-> solution :
- a; // double
- b; // double
- solution_gcd; // gcd(b, a)
- solution_numerator; // -b / gcd
- solution_denominator; // a / gcd
- solution; // double (-b / a)
-> degree 2 :
-> discriminant : Δ = b² - 4ac
-> Δ > 0 -> 2 solutions : x = ( -b / 2a ) +- ( √|Δ| / 2a )
-> Δ == 0 -> 1 solution : x = ( -b / 2a )
-> Δ < 0 -> 2 solutions : x = ( -b / 2a ) +- i( √|Δ| / 2a )
-> solution :
- delta_sign; // + or -
- delta; // Δ
- delta_absolute; // |Δ|
- delta_sqrt; // √|Δ|
- first_term; // double (-b / 2a)
- second_term; // double (√|Δ| / 2a)
6. print solution
---