Commit graph

23 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
NOT XVilka
d3860590ee
librz/util: shared Unicode subscript formatting for bit-vectors and floats (#6418)
Consolidate the Unicode subscript notation used when rendering
bit-vector and float values (the subscript width on a bit-vector
constant, e.g. 0x2c followed by a subscript 8, and the format width
on a float, e.g. .f followed by a subscript 32) into one place, so
the RzIL Unicode exporter, the RzNum value printer, and the
RzNum->RzIL lift cannot drift apart.

RzUtil gains the single source of truth:

  * rz_str_append_subscript() / rz_str_append_superscript() /
    rz_str_subscript() render a number as Unicode subscript or
    superscript digits;
  * rz_bv_width_subscript() / rz_bv_as_unicode_string() build a
    bit-vector's width subscript on top of the str helper;
  * rz_float_format_subscript() renders a float format's width
    subscript (16/32/64/80/128, with the decimal-format marker),
    reusing the same digit renderer.

The RzIL Unicode exporter (il_export_string_unicode.c) is switched
fully onto these: every append_subscript() call site (bit-vector
constant width, cast length, memory indices) now goes through
rz_str_append_subscript(), and the hardcoded per-format subscript
macro is replaced by rz_float_format_subscript(). The exporter's
private subscript-digit table and ut32 glyph helper are removed, so
there is no longer a second, parallel implementation to keep in sync.

Signed-off-by: Anton Kochkov <anton.kochkov@gmail.com>
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-05-29 02:02:58 +08:00
Florian Märkl
c594b413ff
Swap argument order of rz_bv_copy* (#5793)
This brings these copy functions in line with the more common order of
dst, src as used in memcpy and rz_bv_*_inplace functions.
This is a breaking change and callers of rz_bv_copy() and
rz_bv_copy_nbits() must adjust to the new order.
2026-01-14 23:18:34 +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
Giovanni
db1e4993a0
Replace strdup with rz_str_dup (#4634) 2024-09-15 19:12:07 +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
pelijah
9a27c4fe6e
Fix memleak in define_cast_from_value macro (#4407) 2024-03-31 12:05:29 +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
Anton Kochkov
8e4faa3906
Remove scr.rainbow option (#4199)
* Remove scr.rainbow option
* Update librz/util/float/float.c
2024-02-10 12:02:50 +08:00
Heersin
803aa3951e
ARMv7 NEON and VFP for rzil (#3528)
* Export float basic op to op_builder header

* Basic vmov with note and question

* Add vmov for immediate

* Add vmov for NEON and VFP

* Add vmsr, vmrs. shared instruction of vfp and neon done

* Add vector logical operations for arm32 il

* Add vmvn for arm32 il

* Solve op builder for rzil float

* Add vector compare instructions (vceq/vcge/vcle/vcgt/vclt, and abs version)

* Rename vcmp to vec_cmp to avoid conflict with VCMP instruction

* Add vtst of NEON instruction set

* Fix FEQ

* Discard unecessary changes

* Add vldn for multiple n-elements

* Add vldn for single-lane and all-lane

* Add vstn

* Add vcvt for float-integer and float-float

* Check codeql warning

* Add vdup

* Fix according to reviewer

* Add vext

* Add vzip

* Fix reg_bits shadowing

* Add vuzp

* Init some eff as EMPTY for loop-seq

* Add vswap

* Add vadd and vsub

* Add vmul for float point in vfp

* Fix test_validate_forder

* Fix reg binding by add missing reg(fpscr)

* Fix memory broken caused by misuse of REG_VAL and others

* Add vldr and vstr

* Fix some bug in rzil float

* Fix a format typo bug in rzfloat

* Add rzil emulateme test for vfp

* Fix fpscr in db arm32 related tests

* Add extra argument info in vfp test

* Remove duplicated macro of float
2023-07-09 00:43:18 +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
b2ace2664c
Add macroses to generate Inf/NaN for different types (#3373)
* Add macros to generate inf/nan for different types
* Move header dependency to rz_float and multiple renames
2023-02-19 20:55:23 +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
Giovanni
4bd9d19473
RzFloat: Fix endianness conversion (#3079) 2022-10-09 08:05:20 +08:00
wargio
19beda6c66 Refactor softfloat error messages. 2022-09-16 21:55:58 +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