Commit graph

17 commits

Author SHA1 Message Date
مصطفي محمود كمال الدين
59d8c998e5 fix positive zero comparing inequal with negative zero, IEEE754 mandates equality 2026-06-21 03:48:49 +08:00
مصطفي محمود كمال الدين
afd6607fe2
Fix error handling and a percision issue in float core (#6469)
* fix error handling and percision issues in float core
* fix rz_float_cast_float on zero input and add tests
2026-06-14 22:48:44 +08:00
Rot127
25d500a86b
librz/util/float: fix cast of negative zero to integer. (#5291) 2025-08-06 00:06:43 +08:00
Rot127
22089ed1bb
Fix runtime check for float128 values. (#5283) 2025-07-21 08:28:52 +08:00
Rot127
15e051598f
Enable initialization of negative zero and add float neg tests. (#5282)
* Enable initialization of negative zero and add float neg tests.
* Use argument instead of another function to init negative zero.
* Use platform agnostic negative inifinity value.
2025-07-21 08:28:32 +08:00
Khairul Azhar Kasmiran
79814e46b6
Fix #4799: Use Meson to set c_std=c99 (#4828)
* Fix #4799: Use Meson to set `c_std=c99`
* Define `_GNU_SOURCE`
* Use alt syntax in float subtraction
2025-01-13 22:22:23 +08:00
Dhruv Maroo
19ec6ba298
Use SoftFloat 3e for implementing arithmetic operations in RzFloat (#4535)
* Add a new test for checking 80-bit floating point operations

    * New test `f80_ieee_div_test` tests the division of two 80-bit
      floats

* Add SoftFloat 2c as a meson subproject

* Add softfloat code to make the failing test case pass

* Update the hash for the latest softfloat revision

* Implement `rz_float_sqrt` using SoftFloat

* Run the `f80_ieee_div_test` only for x86

* Replace SoftFloat version 2c with 3e

    * 3e has less bugs and more features
    * Modify the implementation in accordance

* Update SoftFloat revision and add a guard around the 80-bit div test

* Use SoftFloat for add, sub, mul operations as well

* Make rem and mod also use SoftFloat functions

    * Also add test for mod and rem, and fix behavior of rem

* Add comment about behavior of mod and rem

* Add comments for tests which have different results for mod and rem

* Simplify usage of loop variable as suggested in review

* Remove unused macro from float.c

* Implement `FMA` and `ROUND` using SoftFloat API

* Add more tests for 80-bit floats

* Change remote to a repository under rizinorg

* Add info about the rounding mode in the Doxygen for rem and mod

* Add comments in tests for rem and mod in `test_float.c`

* Use bitvectors to initialize 80-bit soft floats

    * This makes the tests more portable and hence they can be run on
      any platform

* Remove guards for f80 tests since they are portable now
2024-06-25 22:06:24 +05:30
Florian Märkl
2a9f765582
Weaken f80 assertions in test_float for non-x86 (#4280)
OpenBSD/sparc64 uses 128-bit floats as long double by default while our
tests seeminly assumed either 64-bit or 80-bit, both of which produce
different results than 128 here. Since 80-bit is x86-specific, we check
only the bits we know will be identical between other architectures.
2024-02-21 15:02:05 +01:00
Dhruv Maroo
01c0159f6e Fix the test for ARM and Windows 2024-02-17 15:46:11 +08:00
Dhruv Maroo
87f889efa7 Fix conversion of 80-bit floats
* Add a new unit test for the same
2024-02-17 15:46:11 +08:00
Dhruv Maroo
70fb3be17f 80-bit float initialization works now
* Added a test in `test_float.c` for it
    * It is kind of unfortunate to deal with the idiosyncrasy of 80-bit
      float this way. There are cleaner ways, but they would require
      more refactor, and are probably not worth it since we wouldn't be
      modifying the float code that often.
2024-02-17 15:46:11 +08:00
Giovanni
105bc0ed50
Revert "Add float to raw bitvector conversion. (#3509)" (#3517)
This reverts commit 74c044ad63.
2023-05-20 15:39:31 +08:00
Giovanni
74c044ad63
Add float to raw bitvector conversion. (#3509) 2023-05-14 13:14:11 +08:00
Heersin
2b748567fa
Add fbasic theory to rzil using rz_util/float (#3184)
* Fbasic dev build test

* Add fbasic structure and enums

* Add fbasic op new

* Add fbasic op dup

* Add fbasic op free

* Add partial theory of float

* Add fbasic handlers to pure table default

* Add fbasic stringfy

* Add temporary float functions

* Add rz-float value and evaluation

* Add float json dump functions, todo add mode info in il_opdmp_* functions and compelete il_resolve_pure

* Complete fbasic il in il_export

* Fix detected error in compilation

* Add doxygen for il/definition/float

* Pack float_round function

* Add new version of rounding

* Add cast and convert, todo add 'float_get_sign' and 'float_get_no_bias_exp'

* Add comments and fix new version rounding

* Add util float functions

* Implement theory fbasic : cast, convert and round

* Remove bv_one warning

* Move basic functions into rz_util from definition/float

* Add two basic test cmp and extra format test

* Add test to fsucc, fpred and fneg

* Add round significant test case 1 and fix bug to pass it

* Test round significant and bug fixes

* Add 6 types test cases to round_and_pack function

* Finish round significant and round_pack test with bug fixes and signature changes

* Leave fround as unimplement now

* Pass all test to cast and convert

* Add SPDX header

* Add SPDX header

* Add round to integral float with test and bug fixes

* Add more tests to cast_sint and bug fixes

* Fix mem leak in cast_sfloat

* Replace the deprecated rounding method, fix bugs and pass tests

* Resolve some reviewed issues

* Fix most memleak and bug found

* Remove deprecated round_bv

* Remove unused functions to eliminate warnings

* Fix typo in comments

* Uncommented implmented operations

* Add test cases and bug fixes for fbasic theory in rzil

* Fix ret type of new_bitv_from_* from Bool to BitVector

* Add new float op from f32 and f64
2023-02-15 18:18:40 +08:00
wargio
bf6d162909 Implement float80 and RzFloat to decimal string 2022-11-01 10:58:16 +08:00
wargio
8f40517990 Refactor rz_float_new_from_utXX_as_fXX 2022-09-16 21:55:58 +08:00
Heersin
b13202b934
RzUtil: softfloat support based on bitvector (#2784) 2022-09-14 14:38:22 +02:00