Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 843
dfasdljkhfaskldjhfasklhf Avatar asked Nov 07 '08 13:11

dfasdljkhfaskldjhfasklhf


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C language easy?

Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.


3 Answers

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.)

like image 53
Xiaofu Avatar answered Sep 29 '22 23:09

Xiaofu


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?

like image 33
Jon Skeet Avatar answered Sep 30 '22 00:09

Jon Skeet


The reason is that both single and double are both Floating Point numbers.

single is short for Single Precision Floating Point Number (32 bits)
double is short for Double Precision Floating Point Number (64 bits)

Therefore to call a floating point number float is ambiguous.

http://en.wikipedia.org/wiki/Single_precision
http://en.wikipedia.org/wiki/Double_precision

like image 38
LeppyR64 Avatar answered Sep 30 '22 00:09

LeppyR64