Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests for IEEE 754-2019 compliance #6571

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

anandkaranubc
Copy link
Contributor

Progresses #365

Description

What is the purpose of this pull request?

This pull request:

  • Adds all the tests for testing special cases of log*

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review. labels Apr 5, 2025
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc
Copy link
Contributor Author

image

All checked!

@Planeshifter
Copy link
Member

Planeshifter commented Apr 5, 2025

@anandkaranubc Per failing CI checks, looks like our log10 might not behave as expected for -0. Would you mind taking a look, please?

@anandkaranubc
Copy link
Contributor Author

anandkaranubc commented Apr 5, 2025

Haha, was in the middle of writing the reason :)

Oops, there is a bug. log2 and log10 don't return NINF when x = -0.0. But it works in C.

Mainly because of no type casting on hx in JS.

toWords.assign( x, WORDS, 1, 0 );
hx = WORDS[ 0 ];
lx = WORDS[ 1 ];
k = 0|0; // asm type annotation
if ( hx < HIGH_MIN_NORMAL_EXP ) {
// Case: x < 2**-1022
if ( ( (hx&ABS_MASK) | lx ) === 0 ) {
return NINF;
}

hx still remains a "huge" positive number here and isn't less than HIGH_MIN_NORMAL_EXP

But in C,

Typecasting it back again in int32_t makes it negative again.

xc = x;
stdlib_base_float64_to_words( xc, &hx, &lx );
ihx = (int32_t)hx;
k = 0;
if ( ihx < HIGH_MIN_NORMAL_EXP ) {
// Case: x < 2**-1022
if ( ( ( ihx & STDLIB_CONSTANT_FLOAT64_HIGH_WORD_ABS_MASK ) | lx ) == 0 ) {
return STDLIB_CONSTANT_FLOAT64_NINF;
}

cc: @Planeshifter @kgryte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Math Issue or pull request specific to math functionality. Needs Review A pull request which needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants