Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Floating-point numbers with too long decimal places will lose precision #142

@weucode

Description

@weucode

Description

When set a floating-point value with long demical places,it will move the decimal part forward by about one or more places,sometimes this will lead to some misunderstandings.

For example,if I use two different values to check whether they are equal to a same floating-point,the result values are all true,I'm not sure such behavior should be allowed.

Testcase

namespace NISLNameSpace {
	open Microsoft.Quantum.Intrinsic;


	@EntryPoint()
	operation main() : Unit {
		mutable num = 4.5423904623895424;
		Message($"check {num}" );
		if(num == 4.5423904623895424){
			Message("this is true");
		}
		if (num == 4.542390462389543) {
			Message("this is true too");
		}
	}
}

The output message is shown below.

check 4.542390462389543
this is true
this is true too

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionIssues filed to ask a question

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions