There is a function IntToBin in the unit StrUtils that can give you ...
OK, now without any effort at all for TS we solved his friends homework assignment.Relax, the teacher will reject the use of such built-in function. Plus, IntToBin only gives answer in one's complement. He will still need hammer his head to get the two's complement (despite it's very trivial).
Personally I object to that.
Bart
Relax, the teacher will reject the use of such built-in function.
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.
His friend only has to copy the implementation of said function (for 1 implmentation).Yep, as expected, and that's only if the friend can find where the source code for that function is ;)
Of course this implementation may still be way above the skills he is expected to have, so his friends teacher might still reject it.
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).
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?
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?
Can we be sure that the task was thoroughly prepared and clearly put by the teacher?
Everything may be completeky differnt, of course, from what I supposed. No factual information so far!