Skip to content

Document common trap in arb_set_d #1786

Closed
@rudolph-git-acc

Description

@rudolph-git-acc

Ref. this AskSagemath-question: https://ask.sagemath.org/question/76066/ghost-numbers-when-using-arb/

When I run this simple code in my IDE:

    #include "flint/arb.h"
    
    int main(int argc, char **argv)
    {
    	arb_t a;
    	arb_init(a);
    	
    	slong prec;
    	prec = 256;
    	
    	arb_set_d(a, 1.1);
    	arb_printd(a, 70);
    	printf("  WRONG \n");
    	
    	arb_set_str(a, "1.1", prec);
    	arb_printd(a, 70);
    	printf("  FINE \n");
    	
    	arb_set_d(a, 1);
    	arb_printd(a, 70);
    	printf("  FINE \n");
    	
    	arb_clear(a);
    	return 0;
    }

I obtain:

1.100000000000000088817841970012523233890533447265625000000000000000000 +/- 0  WRONG 
1.100000000000000000000000000000000000000000000000000000000000000000000 +/- 1.7272e-77  FINE 
1.000000000000000000000000000000000000000000000000000000000000000000000 +/- 0  FINE 

Only the arb_set_d command seems to induce this issue and only for non-integer values. Is this a bug or an unavoidable effect?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions