Click here to Skip to main content
15,616,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here I did not typecast like we do in java, but I am getting correct output
Why is that so?

void main() {


What I have tried:

I tried searching in google ..................................
Updated 10-Oct-21 22:40pm
Richard MacCutchan 11-Oct-21 4:19am    
Check the Dart documentation to see how it deals with such expressions.

1 solution

The Dart division operator[^] works on double values. It has a different operator for integer division[^] if you want the same behaviour as Java.

Only the language designers could tell you why it does that. At a guess, they saw how many people were tripped up by the integer division behaviour in other languages, and wanted to avoid that in their language.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900