Dear MariaDB Developer Community,

I hope you are doing well.

I am *Harshit Vijay Kumar*, a final-year undergraduate student in Computer
Science. I have been researching *MDEV-36107
<https://jira.mariadb.org/browse/MDEV-36107>* for *GSoC 2025* and, during
my exploration of operator operations in MariaDB, I came across some
behaviors that caught my attention. To further investigate, I compared
these behaviors with MySQL to understand their differences.

*Observations: *

*(1) Handling Large Number Multiplications Using Exponents*

   -

   Currently, multiplying two large integers results in an *overflow*,
   returning 0 instead of using an exponent-based representation.

SELECT 18014398509481984 * 18014398509481984;
*MariaDB Output:* 0
*SQL Output:* 3.2451855365842673e+32

   - Interestingly, if one of the operands is a *floating-point number*,
   the result is computed without overflow:

SELECT 18014398509481984 * 18014398509481984399405765456789087654390954.0;
*Output:* 324518553658426733978210646499548233026655740664701555572736.0

   - This inconsistency between integer-only and mixed-type operations is
   confusing. A standardized approach, possibly leveraging exponent notation,
   could improve clarity.

*(2) Rounding Floating-Point Outputs*

   -

   MariaDB currently returns full precision in floating-point calculations,
   which can lead to unnecessary precision in practical use cases.

SELECT 1.0376728938476536278903984765 +
1.039876453672890938476536278902345678908765434567890;
*MariaDB Output:* 2.07754934752054456636693475540234567891
*SQL Output:* 2.077549347520544

   - A rounding mechanism would allow for concise representation and reduce
   storage overhead, especially for users unaware of excessive precision in
   their datasets.

*(3) Eliminating Unnecessary Zeros in Floating-Point Representation*
SELECT 1.0000 * 1.0000000000;
*MariaDB Output:* 1.00000000000000

   - While useful in some cases, the inclusion of excessive trailing zeros
   unnecessarily increases storage usage. A more compact representation should
   be considered, where only *significant digits* are retained.

*(4) Implementation of == Equality Operator*

   -

   Currently, MariaDB allows the *assignment operator (=)* for comparisons.
   However, since = is primarily used for assignments, this dual-purpose
   behavior can be confusing.
   -

   Proposal: Introduce a dedicated *== equality operator* for clear and
   intuitive comparisons across *INT, FLOAT, BOOL, and CHAR* types.
   -

   Expected behavior:
   -

      If values match → return 1
      -

      If values don’t match → return 0

Testing & Next Steps

To implement these improvements, I plan to add *test cases* in mysql-test
covering all edge cases for these operators. I will follow the approach
used in the following implementations:

   -

   func_equal.result
   
<https://github.com/MariaDB/server/blob/main/mysql-test/main/func_equal.result>
   -

   func_equal.test
   <https://github.com/MariaDB/server/blob/main/mysql-test/main/func_equal.test>

I would really appreciate your insights on these ideas. If any of these
behaviors have intentional design choices, I would love to understand the
rationale behind them.

Looking forward to your feedback!

Best Regards,

Harshit Vijay Kumar
_______________________________________________
developers mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to