C# Float vs. VB.net Single - Namin' complainin'


Question

Why is it called a single in VB.net? I'm sure there is a good reason but it doesn't seem intuitive to a non formally trained programmer like me.

1
21
11/7/2008 1:06:18 PM

Accepted Answer

BPAndrew's question seems to be really "why float in C# and Single in VB.NET", which noone actually answered, so here's my 2p...

The use of "float" in C# seems to be a throwback to its C/C++ heritage. "float" still maps to the System.Single type in C#, so the keyword just exists for convenience. You could just as well declare the variable as "Single" in C# the same as you do in VB.NET.

(And as stated above, naming them Single/Double actually makes more sense as they are single/double precision floating-point numbers.)

30
11/7/2008 1:38:10 PM

As others have said, they map to "single" and "double" precision binary floating point types. Personally I think it was a sideways step to just name System.Single and System.Double - why not System.Float32 and System.Float64 to match the integer types?


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon