Lars Kuerten
Lars Kuerten

Reputation: 86

Is there a difference in performance writing per example 2 instead 2.0 for double in Dart

I just wondering what changes in terms of performance for writing an int instead a double for double:

double x = 2; instead double x = 2.0

Upvotes: 1

Views: 110

Answers (1)

nvoigt
nvoigt

Reputation: 77324

Since this statement has to be parsed and understood by the compiler at compile time, there is no runtime benefit of one way of writing the constant number over another.

Whether your code may or may not compile a split-microsecond faster is not really of any interest. Write it in a way it is easy to understand for the human reader, because that is the bottleneck when working with code.

Upvotes: 3

Related Questions