java - Proper notation using doubles -


Is it more stylistically acceptable to write constants with ".0" in or without duplicate functions? As

,

double var = 200.0; Double d = var / 250.0; Double H = 1.0 - d;

Vs.

double var = 200; Double d = var / 250; Double H = 1 - D;

Thanks

This is not about style. When you type double var = 200; , then write 200 , which is then converted to two.

It is better to be specific - if you are using double constant, type it twice:

  double D = 200.0; Double one = .01; Double xp = 1e3;  

All of the above are especially important in your second example:

  var = 50; Double d = var / 250;  

I have left the type var on purpose it is not clear what will happen in the form of the d - either Can be 0.2 or 0.0 (if var integer). On the other hand, if you type double d = var / 250.0 , the result will always be 0.2 .


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -