Skip to content

Failure to exactly match some binary floats #182

@seboyden

Description

@seboyden

Slivar is failing to make an exact match to the number 0.03 in a VCF annotation
It appears to be seeing the number 0.03 as its 32-bit binary approximation, about 0.02999999932944774627

In a use case with a filtering threshold using >= or <=, a user could adjust the threshold as necessary to get exact matches,
but in other use cases requiring an exact match ==, this could be a more difficult problem for the user to do a workaround.

$ bcftools query -f %INFO/SpliceAI_pred_DS_AL $VCF
0.03

$ slivar_v0.3.1 expr --vcf $VCF --pass-only --info "INFO.SpliceAI_pred_DS_AL >= 0.03" # Fails to find an exact match
$ slivar_v0.3.1 expr --vcf $VCF --pass-only --info "INFO.SpliceAI_pred_DS_AL == 0.03" # Fails to find an exact match
$ slivar_v0.3.1 expr --vcf $VCF --pass-only --info "INFO.SpliceAI_pred_DS_AL < 0.03" # Matches 0.03 in VCF as <0.03
$ slivar_v0.3.1 expr --vcf $VCF --pass-only --info "INFO.SpliceAI_pred_DS_AL < 0.02999999932944775" # Matches
$ slivar_v0.3.1 expr --vcf $VCF --pass-only --info "INFO.SpliceAI_pred_DS_AL < 0.02999999932944774" # Doesn’t match

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions