Is there a difference between "0f;" and "000f;"?

I have 2 Examples (A & B), I like “B” just cause it’s neat

Example A

private float x = 0f;
private float y = 8f;
private float z = 55f;

Example B

private float x = 000f;
private float y = 008f;
private float z = 055f;

Is there really any difference between the 2 Examples?

They both seem to work the same

@BoredMorman is correct, leading zeros are not observed and considered not significant. [Significant Figures][1] [1]: http://en.m.wikipedia.org/wiki/Significant_figures

2 Answers

2

No difference.

Except the fact that there are redundant 0’s there is no difference.

private float x = 0f; 

is similar to

private float x = 000f;

is similar to

private float x = 00000f;

I'm pretty sure the redundant zeros will be removed on compilation. I could be wrong.

you're correct, example: float num1 = 00001f; float num2 = 0001f; float num3 = 1.0f; resulting IL: IL_0001: ldc.r4 00 00 80 3F IL_0006: stloc.0 // num1 IL_0007: ldc.r4 00 00 80 3F IL_000C: stloc.1 // num2 IL_000D: ldc.r4 00 00 80 3F IL_0012: stloc.2 // num3

By the "redundant 0's", I meant redundant 0's in writing. :-)

@HarshadK I'm definitely not advocating this process. It not good coding practice to write in redundant code on the basis that the compiler will remove it. I was simply clarifying your answer. If the OP is OCD enough to take this approach it shouldn't have any effect on the final product.

Thanks guys