POV-Ray : Newsgroups : povray.off-topic : Unexpected Server Time
28 Jul 2024 20:24:16 EDT (-0400)
  Unexpected (Message 11 to 20 of 30)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: clipka
Subject: Re: Unexpected
Date: 18 Aug 2013 06:20:59
Message: <5210a00b@news.povray.org>
Am 18.08.2013 09:50, schrieb Warp:
> Orchid Win7 v1 <voi### [at] devnull> wrote:
>> On 17/08/2013 05:56 PM, Warp wrote:
>>> Having been a teaching assistant at the computing science lab, I got to
>>> see some pretty weird programs made by students.
>>>
>>> For example, you wouldn't believe how complicated calculating the length
>>> of a 2D vector can become in the hands of an inexperienced programmer.
>>> (This should be a literal one-liner, yet even 100 lines of code were
>>> regularly broken just to do this simple thing.)
>
>> Hmm, yes. I'm just trying to visualise that now... What would I do if I
>> had no idea what I'm doing? (I guess the question is, how many of these
>> programs ever *worked*?)
>
> Mind you, these people generally knew the pythagorean formula to do the
> job (after all, they were university students.) They still managed to
> break the 100-line mark.

That /is/ scary - then again, maybe they didn't know the sqrt() function?


Post a reply to this message

From: Bald Eagle
Subject: Re: Unexpected
Date: 18 Aug 2013 07:00:00
Message: <web.5210a922825e3e9f2c424ebe0@news.povray.org>
> > Mind you, these people generally knew the pythagorean formula to do the
> > job (after all, they were university students.) They still managed to
> > break the 100-line mark.

That's what happens when you're used to programming in Goldberg on a
Governmentium processor.


Post a reply to this message

From: Warp
Subject: Re: Unexpected
Date: 18 Aug 2013 08:27:58
Message: <5210bdce@news.povray.org>
Orchid Win7 v1 <voi### [at] devnull> wrote:
> But you can phrase that as

>    return x ? x : -x;

No, you can't.

Don't blame others for doing mistakes if you are doing them yourself. ;)

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Unexpected
Date: 18 Aug 2013 08:31:59
Message: <5210bebf@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> That /is/ scary - then again, maybe they didn't know the sqrt() function?

The most common problem was that, for some reason, they thought that
you had to calculate the formula differently for positive numbers than
for negative numbers. And since there are four possible combinations of
signs for the two parameters... (Even then you would think that it would
take like 8 lines: Four conditionals and four instances of the same
pythagorean formula. But no, it couldn't be that simple either. You see,
you have to first remove the sign in order to do the pythagorean theorem
with positive numbers only... which kind of reminds me of the abs() problem
referred to by Andrew. I don't even remember anymore how they managed to
get so many lines of code.)

I never quite understood what made them think that you can only calculate
the pythagorean formula with positive values. One would think that they
know that yes, you can raise a negative value to the power of two and that
the result will be positive, but seemingly it's not that simple.

The hilarious (or sad, depending on your persective) thing about it was
that they pretty much ended up writing the same code four times in their
implementation, inside four conditionals, without realizing it.

-- 
                                                          - Warp


Post a reply to this message

From: clipka
Subject: Re: Unexpected
Date: 18 Aug 2013 08:43:30
Message: <5210c172$1@news.povray.org>
Am 18.08.2013 14:27, schrieb Warp:
> Orchid Win7 v1 <voi### [at] devnull> wrote:
>> But you can phrase that as
>
>>     return x ? x : -x;
>
> No, you can't.
>
> Don't blame others for doing mistakes if you are doing them yourself. ;)

It's a creative way of writing "return x" though ;-)


Post a reply to this message

From: Warp
Subject: Re: Unexpected
Date: 18 Aug 2013 09:23:49
Message: <5210cae4@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 18.08.2013 14:27, schrieb Warp:
> > Orchid Win7 v1 <voi### [at] devnull> wrote:
> >> But you can phrase that as
> >
> >>     return x ? x : -x;
> >
> > No, you can't.
> >
> > Don't blame others for doing mistakes if you are doing them yourself. ;)

> It's a creative way of writing "return x" though ;-)

Out of curiosity: Does C#, like C/C++, consider a non-boolean value as
a valid boolean (where a boolean is expected)?

I know that there are some languages that don't, but on the other hand.
C# is kind of in the C family of languages...

-- 
                                                          - Warp


Post a reply to this message

From: clipka
Subject: Re: Unexpected
Date: 18 Aug 2013 09:50:12
Message: <5210d114$1@news.povray.org>
Am 18.08.2013 15:23, schrieb Warp:
> clipka <ano### [at] anonymousorg> wrote:
>> Am 18.08.2013 14:27, schrieb Warp:
>>> Orchid Win7 v1 <voi### [at] devnull> wrote:
>>>> But you can phrase that as
>>>
>>>>      return x ? x : -x;
>>>
>>> No, you can't.
>>>
>>> Don't blame others for doing mistakes if you are doing them yourself. ;)
>
>> It's a creative way of writing "return x" though ;-)
>
> Out of curiosity: Does C#, like C/C++, consider a non-boolean value as
> a valid boolean (where a boolean is expected)?

Me I dunno. Though, thinking about it, Microsoft did various things 
right with C#, so I suspect it won't accept non-booleans there.

> I know that there are some languages that don't, but on the other hand.
> C# is kind of in the C family of languages...

So is Java, but even that insists on proper booleans for tests.


Post a reply to this message

From: Orchid Win7 v1
Subject: Re: Unexpected
Date: 18 Aug 2013 10:40:34
Message: <5210dce2@news.povray.org>
On 18/08/2013 01:27 PM, Warp wrote:
> Orchid Win7 v1<voi### [at] devnull>  wrote:
>> But you can phrase that as
>
>>     return x ? x : -x;
>
> No, you can't.
>
> Don't blame others for doing mistakes if you are doing them yourself. ;)

The guy took about 6 minutes to come up with the answer illustrated. My 
problem was in only spending 6 seconds. :-/


Post a reply to this message

From: Warp
Subject: Re: Unexpected
Date: 18 Aug 2013 10:42:49
Message: <5210dd68@news.povray.org>
Orchid Win7 v1 <voi### [at] devnull> wrote:
> On 18/08/2013 01:27 PM, Warp wrote:
> > Orchid Win7 v1<voi### [at] devnull>  wrote:
> >> But you can phrase that as
> >
> >>     return x ? x : -x;
> >
> > No, you can't.
> >
> > Don't blame others for doing mistakes if you are doing them yourself. ;)

> The guy took about 6 minutes to come up with the answer illustrated. My 
> problem was in only spending 6 seconds. :-/

The problem is that the answer above doesn't work.

-- 
                                                          - Warp


Post a reply to this message

From: Orchid Win7 v1
Subject: Re: Unexpected
Date: 18 Aug 2013 10:43:02
Message: <5210dd76$1@news.povray.org>
On 18/08/2013 02:23 PM, Warp wrote:
> Out of curiosity: Does C#, like C/C++, consider a non-boolean value as
> a valid boolean (where a boolean is expected)?

No.

(I just had to look that up.)

Apparently C# does not support implicit (or even explicit) conversion 
between bool and any other type.

Which is weird, because this is the exact same programming language 
where if you create an enum, it's actually just an int, as far as the 
type system is concerned...

(Oh, but bool isn't an enum. Naturally.)


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.