abaplint / transpiler

ABAP to JS transpiler & runtime
https://transpiler.abaplint.org
MIT License
82 stars 23 forks source link

Half up rounding not done for integer = '45141.58832' (actual: 45141, expected: 45142) #1431

Closed sandraros closed 7 months ago

sandraros commented 7 months ago

There's a failure with abap2xlsx unit test (see the log corresponding to the pull request https://github.com/abap2xlsx/abap2xlsx/pull/1197).

Probably, it's related to this code:

* 45141.58832 (2023/08/03 14:07:11) ip_exact = abap_false -> 2023/08/04
    TRY.
        ep_value = zcl_excel_common=>excel_string_to_date( ip_value = '45141.58832'
                                                           ip_exact = abap_false ).
        cl_abap_unit_assert=>assert_equals(
          act   = ep_value
          exp   = '20230804' ).

and zcl_excel_common=>excel_string_to_date:

  METHOD excel_string_to_date.
    DATA: lv_date_int TYPE i.
    DATA lv_error_text TYPE string.

    CHECK ip_value IS NOT INITIAL AND ip_value CN ' 0'.

    TRY.
        IF ip_exact = abap_false.
          lv_date_int = ip_value.
        ELSE.
          lv_date_int = trunc( ip_value ).

The code which should be executed is lv_date_int = ip_value, where ip_value = '45141.58832'. I guess that the transpiler calculates 45141, but it should calculate 45142.

Thank you.

larshp commented 7 months ago

thanks, note its not a required check in abap2xlsx, also feel free to ping me in the PR if it fails

looking into it now

sandraros commented 7 months ago

Oh I didn't realize it was optional, no hurry so. Thank you.

larshp commented 7 months ago

reproduced, image

larshp commented 7 months ago

@sandraros try again, 2.8.24 published

I've also opened https://github.com/abap2xlsx/abap2xlsx/pull/1207

sandraros commented 7 months ago

It's now okay, thank you very much!