If you want background, read this thread
http://www.vbforums.com/showthread.php?p=3156598
I have no ill will towards Tom, and everyone's opinion is respected on here.
Now I just want to know what everyone else thinks with regards to this.
Printable View
If you want background, read this thread
http://www.vbforums.com/showthread.php?p=3156598
I have no ill will towards Tom, and everyone's opinion is respected on here.
Now I just want to know what everyone else thinks with regards to this.
Yes my opinion is that its a number. I dont see what else it would be.
[James Bond Accent]002 Dog, Rob Dog.[/James Bond Accent]
IAN = Is A Number function. :D
A string.Quote:
Originally Posted by Atheist
Anyway, i'll say string simply because the two zeros are redundancies. a number never contains redundant digits. And don't talk about 2.00 instead, because a little reading would tell you that putting the two zeros after the decimal is meant to show the accuracy to which the number has been calculated.
No, as either its 002 or 2.00 its the same exact value and both are numbers. Signifigant digits are just formatting per-se if the value is truely 2.00 but ultimately its off topic as the original discussion was on Integers and not Singles or Doubles. :)
The question in the OP (of the original thread) referred to whether or not it is a number inside of visual basic. It is not.
The word "integer" refers to the visual basic variable that is compiled to a System.Int32 value type. That allocates a section of memory on the stack to store the value 2. It does not allocate a section of memory on the stack to store the value 002. Nor is there any other numeric data type that stores the leading zeros when compiled to the IL and CLR. Therefore, inside visual basic, 002 is not a number.
Edit: Ironically enough, since I'm the one who started arguing over this pedantic irrelevancy, I misread the poll question and answered that it's a number.
I guess you can call it 02
Goodness... what a read! :D
It all comes down to the same thing:
Now: Is a string of a number (integer) an integer or a string?Quote:
Originally Posted by Probably someone clever
Interesting...
*Please note that I have not voted on the poll for the fear of Kregg returning and beating me to a pulp*
A STRING of an int. Therefore, it's a string. An int will NEVER contain redundant zero's at the front of it.
:rofl: This thread will never see it's end! :lol:
So if a a lottery...guy...yells out "the person with lottery ticket number 002 is the winner of this brand new spoon!", would you really stand up and correct him: "String...its a string!"?
So, myNum would be '00000010'. Does anyone say '00000010' is not a number? It has leading zeros too.Code:byte myNum;
myNum = 2;
002 is a number.
Those aren't leading zeros. That's a byte, so all the zeros are bits and have distinct values that mean something. Leading zeros are something completely different.Quote:
Originally Posted by Disiance
I don't like to be pedantic but the very definition of leading leads me to think that as those zeros come before the two they should lead the reader to think that they are in fact leading. I like to lead by example so I would like you to prove to me that:
00000002
Is different from:
00000002
Is different from:
20000000
I vote number, for this reason:
Code:Dim myInt as Integer = 002
Dim myString as String = 002
at least a trinary number
But that second one will fail, assuming Option Explicit is enabled. So, let's try this another way:Quote:
Originally Posted by wild_bill
Here, we clearly see that 002 is a string, not an int.Code:Dim myInt as Integer = 002
Dim myStr as String = "002"
MessageBox.Show(myInt) 'will display "2"
Messagebox.Show(myStr) 'will display "002"
:)
The point of the main thread was thaterrors, hence 002 with no quotes is not a string.Code:Dim myString as String = 002
And 002 as an integer resolves to 2, therefore 002 is not an integer. I sense a paradox.
All literal numbers on this forum and in code are represented by strings. Therefore, everything in code is a string, but some may be numbers.
It's both, probably clsoer to a number though..... 002 is a representation of the number 2. In excel.... type in2.... you get 2. Type in 0002, you get 2. Now format the cell to Custom Format "0000"... you get 0002. It's a display representation of the underlying value. As a number, the leading 0's are "insignificant" but in a textual format, they can make all the difference.
-tg
Let's assume some genius develops a deca-state storage method, so we can store values as 0-9 instead of 0/1.
If I register 0x000000FD-0x000000FF for a variable, deca-value '002', then
FD - 0
FE - 0
FF - 2
Next, my program requests the value of that variable, the computer then retrieves '002', NOT '2'. The value itself is being retrieved, it is never truncated unless it is presented to the user. I pass it to a function, it is passed as '002', but if I tell the program to Msgbox myVar, it shows as '2' because the program truncates it for display purposes.
(I appologize if my use of memory addresses is off, you get my point...)
In this case, I feel that the best answer to the OP is that converting that string to a number should only be done if you understand what it is you want from it. It is a string that can be converted into a number, but it can't be converted into a number than resembles the string. Therefore, I would call it a string.
However, I really think this whole discussion should have been dropped by all parties a loooooong time ago. Neither of the two main people on each side is stupid, and they both fully understand the basic concept of what the other is saying, so the entire argument comes down to semantics. All that really matters, right from the start, is that the OP posted an ambiguous question, and both sides came up with different views on the ambiguity.
why are you attempting to redefine what constitutes a number? what did numbers ever do to you?
And it's very simple really: NUMBERS DON'T HAVE LEADING ZEROS. REDUNDANCY IS NOT A FEATURE IN MATHEMATICS. STOP TRYING TO SOUND CLEVER WITH YOUR STUPID LITTLE CODING TRICKS. BUY A TEXTBOOK. GET A CLUE.
Is black a colour?
Colors aren't colors. They're merely the wavelengths of light that are reflected back. Black doesn't reflect any, white reflects all.
But we perceive (human-visible) wavelengths as colours, therefore colour is a perception.
So... say I have 4 bits representing... we'll say the number 10:
1010
but unfortunately I need 16 bits for an operation so I sign extend and it becomes...
0000 0000 0000 1010
did my number just become a string?
Taking it down to that level, nothing is a string OR an integer. It's all bits. Tiny bumps that mean "on" or "off" that are interpreted as whatever their definition is. That point renders the entire discussion null and void.
Which is almost redundant, as a void method returns null...
No, it is still very much a number, just expressed in a different base.
Bits can represent either numbers or strings. You don't have either until you decide that you want bits X to Y to represent one or the other (or something unrelated, like a custom type).
Likewise, type-casting does not change data but merely the way in which it is interpreted.
It's only a number if you want it to be a number.Quote:
Originally Posted by dsheller
Then by that logic, 5 can equal banana, whereas 10 can be apple... or pick your favorite object and number and have them equal each other.
Edit: I say we ask Dr. Math.
Computers work in bits. Bits, as timeshifter explained, are either on (1) or off (0). Because of this limitation, computers cannot make use of the concept of data types; they merely manipulate bits in predefined manners. It is thus the job of a compiler to enforce the manner in which these bits are interpretated into higher-level types.
Computers do not have any concept of strings.
If you cannot grasp this concept then I am afraid you will struggle with programming of any sophistication.
Read my long opinion here.:thumb:
... ...
So, by mean of a mathematics numeric system, 002 and 2 are two of infinite ways to present the number "two".
And 002 is really a number in this system.
... ...
Haha, I am very aware of what computers use to operate seeing as I had to build an instanciation of one (not a real instruction set, some limited one they have you build for learning EE), but had all the integral parts nonetheless. However, you and Timeshifter are assuming base 2 is only for computing -- it isn't.Quote:
Originally Posted by penagate
Anhn, your theory is incorrect. "Two" is not a number. 2 is, and 002 might be (I still have not decided) but "two" is definitely a string. ;)
:afrog:
I know what you mean, but you put that in a wrong environment.Quote:
Originally Posted by BillGeek
That should be in "English language" (a human being talking language) not a "programming language".
When I use my own language to explain to my students, I replace the word "two" with the equivalent word "hai".
If using French, please replace that word with "duex", or "due" for Italian, or "dos" for Spanish, "dois" for Portuguese,... Are they all correct? What else?
What is the meaning of "string" in plain English? Ask your grandpa or grandma.
That is exacly what I was hoping for. :thumb:Quote:
Originally Posted by anhn
I have made up my mind: It's a value. :afrog:
In a literal sense, it's a string.
In a programming sense, it's an integer. (Or rather, a number ;))
But what I'll do from now on is cast everything. :D
*someone will probably find something wrong with that code...*VB Code:
Dim vTemp As Variant 'I want a number? No prob AnotherIntVar = CInt(vTemp) 'I want a string? No prob AnotherStrVar = CStr(vTemp)
You didn't declare all your variables.Quote:
Originally Posted by BillGeek
It can be the other way around as well if you enumerate them.Quote:
Originally Posted by dsheller
So how would one express this in significant form?
2x0^2?
:D
Easy.
2x0^2
:afrog:
I guess it would be called insignificant form.
You're an insignificant form.
Leading digits are critically important in binary. I'll limit this to a signed byte for simplicity...
2 == 00000010
-2 == 11111110
In the latter, the leading ones don't literally mean 1 they are purely to indicate the negative property of the number. To convert this to human-sensible "-2" one has to do a bitwise not and then add one.
after bitwise not: 00000001 (positive 1)
after adding one 00000010 (positive 2)
Then, since you knew it was a negative number to begin with, you just stick a "-" on the front to give you "-2".
So you see in binary processing at least, leading digits are vitally important. Modern processors do this because it enables them to use the exact same circuits to perform mathematical operations on a number whether it is positive or negative without having to handle each case separately.
We should limit here with NATURAL NUMBERS (N-set, non-negative integers) only. For Z-set (including negative numbers) probably we should have another thread.
002 is the amount of liters of coffee I drink in a day. :afrog:
Redefine the argument until you win it once and for all! Good plan. :DQuote:
Originally Posted by anhn
No, we should limit it to the value types held by the .NET programming langauge. Nothing else matters in the discussion.Quote:
Originally Posted by anhn
No. If you were using an integer, you never had 4 bits to begin with. You had 64 bits. The first 60 were zeros and the last 4 were 1010.Quote:
Originally Posted by dsheller
Ok, let's expand on this a bit. Suppose we had:Quote:
Originally Posted by dsheller
Dim stick, stone1 as integer
Dim stone2 as string
stick = 2
stone1 = 002
stone2 = "Blue"
Now, it would be entirely possible to convert stick or stone1 into strings, but they would convert to strings. Similarly, you could cast stick to a long, a short, or even a byte, and it should also be obvious that you couldn't do the same with stone2, because it isn't a number of any sort. However, it may not be obvious that you also can't cast stone1 to any other type.
Do you know why that is?
overflow.
I my world zero is the absence of sugar.
You are right and because of that you are wrong. What gets stored on the stack isQuote:
Originally Posted by Tom Sawyer
00000000000000000000000000000010
I am awfully sure that the computer doesn't care what you think about leading zero's, it does.
On second thought it is both and neither.
2 <----- Is just some pixels on my screen. When my brain(is it AM/PM) interprets it, it is TWO. My brain knows that it is a number, but it might be a bad drawing of the Cobra insignia on my buddies mustang. If I am trying to program or make Tom S angry then
Dim TomS As String, two As Int32 = 2
TomS = "00000" & two.ToString : two = Int32.Parse(TomS) + 0
Debug.WriteLine(TomS)
Debug.WriteLine(two)
Those aren't leading zeros. They're bits. The two concepts are completely different.Quote:
Originally Posted by dbasnett
Is 0 base2 = 0 baseAnything?
I don't know what base2 is. Could you provide code?Quote:
Originally Posted by dbasnett
AKA Binary