Recent

Author Topic: [Help] Decimal into binary system  (Read 12590 times)

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: [Help] Decimal into binary system
« Reply #15 on: February 08, 2017, 03:42:47 pm »
I fully agree, Bart. And I don't like the idea of accepting donations which comes up from time to time in this context.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8744
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [Help] Decimal into binary system
« Reply #16 on: February 08, 2017, 07:38:51 pm »
His friend only has to copy the implementation of said function (for 1 implmentation).
Of course this implementation may still be way above the skills he is expected to have, so his friends teacher might still reject it.
Yep, as expected, and that's only if the friend can find where the source code for that function is ;)
I still think however that we should help people who ask for this, but (especially for homework assignments) we should not give away code, but give hints and tips (and possibly minor corrections) on the code they can show us.
Indeed, that's what I always do, but only and only if, there's an existing visible and responsible effort (not necessarily code, could be idea or something else, but has to be done by OP him/herself and not a copy from somewhere, easily confirmed by asking the OP to explain it) so at least I can start thinking what kind of hints I should give. I think we should help those who are willing to learn, but not those who are trying to escape their responsibility (yes, there are people with this mindset, and I've met many of them).

Lupp

  • New Member
  • *
  • Posts: 31
Re: [Help] Decimal into binary system
« Reply #17 on: February 08, 2017, 11:10:31 pm »
Ok, I was the one to post the code. (I didn't give away anything.) I also am a retrired teacher. And I know that there arose new problems concerning homeworks and many other things from the technical innovations of the last few decades some of which we are using (and feeding) here. These are problems teachers (and the "educational system") have to consider and to solve. Nobody here should feel urged to do it for them. Let's demonstrate good style with every respect. That's the best we can do to act out our pedagogic impetus.

A few comments on the example now:
The two's complement is a nontrivial concept. Someone who doesn't feel competent at least on a level to be able to start with a task as posted, will also not be able to understand and to apply the concept except in a purely mechanical way.
Isn't it the teacher's role to prepare the basis and to answer questions?

The first question concerning the original post I had in mind was: What is a 'decimal number' in this context? Please tell me if you think this is wrong: "It must be a string of decimal digits". (Can we be sure there isn't a sign and/or a decimal point / a scaling factor in the E notation?) Most likely we have an "unsigned integer", first variant,  as defined under 1.6 in the reference guide.

If so:  Can anybody here help by hints to find a way to write a Pascal routine for the conversion? Can we do it ourselves from scratch extemporizing?
Why should we? We will use the built-in function StrToInt. (Funny Name!) And if we are very clever we will in addition check if the "decimal number" was actually decimal or probably ... (there are 4 variants).

Next: "How should the number look after it was converted into the "binary system". Should it be dyadic written in "0" and "1"? Why not Gray code which also is binary?

...

Can we be sure that the task was thoroughly prepared and clearly put by the teacher?
Can we be sure that just the student was too lazy to work on it?
What are the reasons making such a task an appropriate homewirk for a beginner's programming class?

Everything may be completeky differnt, of course, from what I supposed. No factual information so far!

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: [Help] Decimal into binary system
« Reply #18 on: February 09, 2017, 02:51:42 am »
Calm down sir. You're not the one to blame.

At the very beginning the TS was asked to provide more information: "And what have you got so far?" By knowing how far his (or his friend) know about the problem or has done or at least already in his mind, we can better provide helps. But he answered with the thing that out of what I ever guess.

The code you provided isn't totally useless. At least he now can study how it works. If the student really wants to be a programmer, he will make a way to understand the code. But if he is a 'lazy' student, he will just submit the code to his teacher. So if he really is the lazy one, why should we care. Everyone is a winner. You have showed that your code works, we voiced our voice and the student got the code.
« Last Edit: February 09, 2017, 03:03:32 am by Handoko »

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: [Help] Decimal into binary system
« Reply #19 on: February 09, 2017, 06:43:29 pm »
Ok, I was the one to post the code. (I didn't give away anything.) I also am a retrired teacher.
...
The two's complement is a nontrivial concept. Someone who doesn't feel competent at least on a level to be able to start with a task as posted, will also not be able to understand and to apply the concept except in a purely mechanical way.
Isn't it the teacher's role to prepare the basis and to answer questions?

Of course the task at hand is not trivial.
The fact that one's complement and two's complement implementation is asked for implies that the student is supposed to understand what that is (I would have to google that).

The problem I am having with TS is that he did not show us that he (or his friend) made any effort at all.
I do not even require him to show me working code.
I want to see that he has thought about the problem and has at least tried to make an algorithm to solve the problem at hand.
This can be in "natural language" or pseudo code.

I would at least have expected (for "direct" method) that he would have come up with a solution that involves repeated "divide by 2 and see what the remainder is".
From that concept we could have helped him.

If so:  Can anybody here help by hints to find a way to write a Pascal routine for the conversion? Can we do it ourselves from scratch extemporizing?

For the most simple implementation: yes we can.
For one's complement: I think I can, for two's complement I would probably have to ask for help as well.
Difference is that for me this would not be homework and people around here know I'm legit, so they are probably inclined to give me sample code or point me to resources that help me make my own implementation.

Can we be sure that the task was thoroughly prepared and clearly put by the teacher?

I sincerely hope so.

Everything may be completeky differnt, of course, from what I supposed. No factual information so far!

Because TS did not respond at all.

He has moved on to another forum where he got a ready-made answer and submitted that (or he has failed because the deadline has expired).

Bart

 

TinyPortal © 2005-2018