Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 666 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
0 == NULL? #228459
09/19/08 17:59
09/19/08 17:59
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
I got a bit confused why the engine does not differ between 0 and NULL. Is there a reason for it? Because it is a lot more handy if you can distinguish between these things. As example if you want to determinate, that a variable didn't get value OR has the value 0.

It would be great if that can be added.

Thank you
Scorpion

Re: 0 == NULL? [Re: Scorpion] #228460
09/19/08 18:03
09/19/08 18:03
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Whats the difference between 0 and NULL? I thought its just two ways to express the same thing.

Re: 0 == NULL? [Re: Spirit] #228463
09/19/08 18:08
09/19/08 18:08
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
0 is the integer zero, indicating a variable, integer, double (...)

Imagine 0 as the byte "00000000"

NULL is a pointer to a zero memory address that contains... well, Nothing. NULL is neither "0" nor has *any* value.


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: 0 == NULL? [Re: Michael_Schwarz] #228464
09/19/08 18:11
09/19/08 18:11
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
No, NULL is not a pointer to a zero memory address. In C/C++ NULL is a constant with the value 0x00000000. Which is the same as 0. Thats why I didnt understand what Scorpion meant.

Re: 0 == NULL? [Re: Spirit] #228465
09/19/08 18:14
09/19/08 18:14
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
it may be in C-Script, but in many other languages the comparison

if(0 == NULL)
{
echo "The same";
}

will never be true.


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: 0 == NULL? [Re: Spirit] #228466
09/19/08 18:14
09/19/08 18:14
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
litec.h:
#define NULL 0

Re: 0 == NULL? [Re: Lukas] #228467
09/19/08 18:16
09/19/08 18:16
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
if (0 == NULL)

is the same as

if (0 == 0)

and always true in any language. Try it.

Re: 0 == NULL? [Re: Spirit] #228481
09/19/08 21:20
09/19/08 21:20
Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
T
TWO Offline

Serious User
TWO  Offline

Serious User
T

Joined: Jan 2006
Posts: 1,829
Neustadt, Germany
Python: 0 == nil -> false

As you can see nil is a special type in python and not equal 0 to indicate that an object is invalid. And maybe in many other script languages too, because it's a handy feature.

NULL is just an old C-Lang thing. I use always 0 in my code.

Re: 0 == NULL? [Re: TWO] #228486
09/19/08 21:35
09/19/08 21:35
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
c#

0 == null > false

php

0 === null > false


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: 0 == NULL? [Re: TWO] #228487
09/19/08 21:36
09/19/08 21:36
Joined: Jan 2007
Posts: 1,619
Germany
Scorpion Offline OP
Serious User
Scorpion  Offline OP
Serious User

Joined: Jan 2007
Posts: 1,619
Germany
Well I think I posted this a bit too fast. I looked it up and it's really defined as 0 (or in C: (void*)0 ). So I was misinformed there.

But then may I ask the question why that NULL exists? When is/was it used for which purpose?

Page 1 of 2 1 2

Moderated by  aztec, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1