|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On February 12 2013 10:19 darkness wrote:So I have this little problem to solve: Show nested quote +You are in charge of recording marks for a group of students. Input a list of marks. Input ends with 0 (0 itself is not someone's mark). Output the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60. I just need a hint how to get input like this in C. Also, how should I go about storing marks? Is this a dynamic memory (heap) matter? I already know about getchar and scanf, but are they enough? Maybe getchar() and putchar()? Please don't bother to give me the solution. I just need a little help.  Thanks.
This ought to get you on the right track:
char * fgets ( char * str, int num, FILE * stream );.
|
On February 12 2013 10:19 darkness wrote:So I have this little problem to solve: Show nested quote +You are in charge of recording marks for a group of students. Input a list of marks. Input ends with 0 (0 itself is not someone's mark). Output the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60. I just need a hint how to get input like this in C. Also, how should I go about storing marks? Is this a dynamic memory (heap) matter? I already know about getchar and scanf, but are they enough? Maybe getchar() and putchar()? Please don't bother to give me the solution. I just need a little help.  Thanks. How are you supposed to store these inputs? That's the real question. You can just use scanf -it's perfect for this.
|
On February 12 2013 10:28 CecilSunkure wrote:Show nested quote +On February 12 2013 10:19 darkness wrote:So I have this little problem to solve: You are in charge of recording marks for a group of students. Input a list of marks. Input ends with 0 (0 itself is not someone's mark). Output the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60. Sample Input 88 71 68 70 59 81 91 42 66 77 83 0 I just need a hint how to get input like this in C. Also, how should I go about storing marks? Is this a dynamic memory (heap) matter? I already know about getchar and scanf, but are they enough? Maybe getchar() and putchar()? Please don't bother to give me the solution. I just need a little help.  Thanks. How are you supposed to store these inputs? That's the real question. You can just use scanf -it's perfect for this. I fully agree. Scanf is perfect. And the 0 just requires telling the user to input "0" after a space at the end and telling the program to stop at the "0".
(So glad I can understand things like this now :3)
|
Well I just started learning about classes and objects in Python... And it's not going so well. For some reason I just do not understand objects through and through. I feel like there's something fundamentally wrong with my way of thinking about it.
For the past two days I've been tackling a bunch of "simple" problems. We pretty much went from lists to classes/objects and this stuff is just flying over my head compared to previous lessons. I'm about to head down to the remedial hall to get some help tomorrow because if I can't figure this out on my own after two days then this is a problem... Before that I was hoping I could come here and ask for your advice on it. Here's the sort of problem I'm dealing with.
Problem (from myProgrammingLab for those of you who are familiar) + Show Spoiler +Write the definition of a class Player containing: An instance variable name of type String , initialized to the empty String. An instance variable score of type int , initialized to zero. A method called set_name that has one parameter, whose value it assigns to the instance variable name . A method called set_score that has one parameter, whose value it assigns to the instance variable score . A method called get_name that has no parameters and that returns the value of the instance variable name . A method called get_score that has no parameters and that returns the value of the instance variable score . No constructor need be defined.
Here's my code after dozens of attempts, I even tried a few more while writing this post... + Show Spoiler +class Player : def __init__ (self, name = "", score = 0): self.set_name(name) self.set_score(score) def set_name(self): name = self.set_name def set_score(self): score = self.set_score def get_name(): return name def get_score(): return score
Usually the CodeLab will accept simple answers, and the lines of code they ask for is pretty elementary compared to the brain teasers the book has for its exercises so I am definitely doing something horribly wrong. The Lab keeps telling me I should "use object"... which I don't really understand. I feel like the more time I spend on this, the more confused I get about classes and objects... From my understanding the object in this class would be self, name, and score, but I feel like this should just be done with self, and have self.name = name and self.score = 0.
Or of course I am just a big idiot who just needs someone to correct me, and they could probably do it in a sentences because this is probably very simple ;_; Please help.
Logged 16 attempts today... my professor must be like wtf is this...
|
On February 13 2013 02:28 Snuggles wrote:Well I just started learning about classes and objects in Python... And it's not going so well. For some reason I just do not understand objects through and through. I feel like there's something fundamentally wrong with my way of thinking about it. For the past two days I've been tackling a bunch of "simple" problems. We pretty much went from lists to classes/objects and this stuff is just flying over my head compared to previous lessons. I'm about to head down to the remedial hall to get some help tomorrow because if I can't figure this out on my own after two days then this is a problem... Before that I was hoping I could come here and ask for your advice on it. Here's the sort of problem I'm dealing with. Problem (from myProgrammingLab for those of you who are familiar) + Show Spoiler +Write the definition of a class Player containing: An instance variable name of type String , initialized to the empty String. An instance variable score of type int , initialized to zero. A method called set_name that has one parameter, whose value it assigns to the instance variable name . A method called set_score that has one parameter, whose value it assigns to the instance variable score . A method called get_name that has no parameters and that returns the value of the instance variable name . A method called get_score that has no parameters and that returns the value of the instance variable score . No constructor need be defined.
Here's my code after dozens of attempts, I even tried a few more while writing this post... + Show Spoiler +class Player : def __init__ (self, name = "", score = 0): self.set_name(name) self.set_score(score) def set_name(self): name = self.set_name def set_score(self): score = self.set_score def get_name(): return name def get_score(): return score Usually the CodeLab will accept simple answers, and the lines of code they ask for is pretty elementary compared to the brain teasers the book has for its exercises so I am definitely doing something horribly wrong. The Lab keeps telling me I should "use object"... which I don't really understand. I feel like the more time I spend on this, the more confused I get about classes and objects... From my understanding the object in this class would be self, name, and score, but I feel like this should just be done with self, and have self.name = name and self.score = 0. Or of course I am just a big idiot who just needs someone to correct me, and they could probably do it in a sentences because this is probably very simple ;_; Please help. Could is just not be that it wants you to demonstrate the class by using objects of it? I don't know how CodeLab works, but that's what it sounds like... so make a few player objects and use the methods on them.
|
No it wants me to write out the Class, not use it. At some point I remember getting some feedback showing the input, how it runs through my methods.
Here's the problem before that one that I managed to get right.
Problem + Show Spoiler +Write the definition of a class Counter containing: An instance variable named counter of type int . A constructor that takes one int argument and assigns its value to counter A method named increment that adds one to counter . It does not take parameters or return a value. A method named decrement that subtracts one from counter . It also does not take parameters or return a value. A method named get_value that returns the value of the instance variable counter .
Answer + Show Spoiler +class Counter: def __init__(self): self.counter = 0 def increment(self): self.counter += 1 def decrement(self): self.counter -= 1 def get_value (self): return self.counter
They took that one in real easily. I really don't know where the hell I messed up in the Player problem...
|
On February 13 2013 02:28 Snuggles wrote:Well I just started learning about classes and objects in Python... And it's not going so well. For some reason I just do not understand objects through and through. I feel like there's something fundamentally wrong with my way of thinking about it. For the past two days I've been tackling a bunch of "simple" problems. We pretty much went from lists to classes/objects and this stuff is just flying over my head compared to previous lessons. I'm about to head down to the remedial hall to get some help tomorrow because if I can't figure this out on my own after two days then this is a problem... Before that I was hoping I could come here and ask for your advice on it. Here's the sort of problem I'm dealing with. Problem (from myProgrammingLab for those of you who are familiar) + Show Spoiler +Write the definition of a class Player containing: An instance variable name of type String , initialized to the empty String. An instance variable score of type int , initialized to zero. A method called set_name that has one parameter, whose value it assigns to the instance variable name . A method called set_score that has one parameter, whose value it assigns to the instance variable score . A method called get_name that has no parameters and that returns the value of the instance variable name . A method called get_score that has no parameters and that returns the value of the instance variable score . No constructor need be defined.
Here's my code after dozens of attempts, I even tried a few more while writing this post... + Show Spoiler +class Player : def __init__ (self, name = "", score = 0): self.set_name(name) self.set_score(score) def set_name(self): name = self.set_name def set_score(self): score = self.set_score def get_name(): return name def get_score(): return score Usually the CodeLab will accept simple answers, and the lines of code they ask for is pretty elementary compared to the brain teasers the book has for its exercises so I am definitely doing something horribly wrong. The Lab keeps telling me I should "use object"... which I don't really understand. I feel like the more time I spend on this, the more confused I get about classes and objects... From my understanding the object in this class would be self, name, and score, but I feel like this should just be done with self, and have self.name = name and self.score = 0. Or of course I am just a big idiot who just needs someone to correct me, and they could probably do it in a sentences because this is probably very simple ;_; Please help. Logged 16 attempts today... my professor must be like wtf is this... This might be silly, but based on your post before my reply I would try writing the class without constructor. I know that the problem statement doesn't explicitly state that you should not write one, but the Counter problem statement does explicitly state you have to include a constructor, and the Player problem statement hints that they are looking for a solution without constructor.
[Edit] Just spotted: The line name = self.set_name sets a local variable 'name' (local to the method) to point to the method set_name, which is not what you want. What you're looking for is something like this:
def set_name(self, name): self.name = name
In your get_xxx methods, you aren't returning an instance variable (self.xxx), but either a local or global variable (depending on which one exists) which Python obviously can't find, because none exists.
|
Hey guys, thanks for helping me last time. I have another thing that I struggle with.
Say you have a double variable with this value:
double value = a / b;
let's say 'value = 2.283214570' after division
'a' and 'b' are both integers.
Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2
Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement.
|
Anyone here have any experience in .NET with hostname resolution via proxy servers?
Basically, the jackasses in our network team decided it's a security risk for any computer on the network to resolve an internet hostname to an ip address, unless by means of the proxy server. This poses a problem for one of our existing custom apps that handles automatic FTP processes. Since it connects to a remote FTP server by hostname, it no longer works. We've sidestepped the issue temporarily by adding the host names directly to the server's hosts file, but this obviously is not a good solution in the long term.
I did some googling and couldn't really find anything. I need to be able to resolve an internet hostname to an ip address, the caveat being that I have to do it using a proxy server. Any help would really be appreciated. I can work with either VB.NET or C#.NET. Thank you!
|
On February 12 2013 08:07 Hitch-22 wrote: My error is this:
error: CSInfoCore is abstract; cannot be instantiated arrayCourses[arrCouCompanion] = new CSInfoCore(creditInput, ...)
This follows for the next 4 instantiated sections (one after another).
I can't remove the abstraction, however, because then I get the error (Speaking of classes CSInfoCore through Electives) that you can't edit an abstract method without an abstract class.
THANKS! (This is due tonight, put a lot of time in it, if anyone can put in some good ideas or see where I screwed up that'd be great!)
I would like to help you, but I'm going to need more info. My guess is that you're misusing abstract classes, and that you don't see what consequences that has. It looks like you're using abstract classes to override existing methods. You don't need abstract classes to do that, and by definition you cannot instantiate abstract classes. I think that if I understood what you were trying to accomplish I would be able to help. If you PM me we may be able to get in touch in a more convenient way (google talk or such)
:EDIT: Apparently I confused AM and PM, and this problem is already due. So probably my help comes too late.
|
On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8 
Something like
double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc.
|
On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement.
Make sure when you calculate "value" that you are actually getting decimals. If your A and B are ints, then there is a good chance you are doing integer division which will never have any decimal places.
|
On February 13 2013 05:32 supereddie wrote:Show nested quote +On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: double value = a / b; let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8  Something like double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc.
Awesome. This code only needs slight modification to make it work though.
Math.Truncate = trunc in C Math.Pow = pow in C
But yeah, this is irrelevant. 
Thanks.
Edit: Actually, it seems I've forgotten to say it's for C, but yeah... it's obvious how to fix this. 
Edit 2: You may also want to change 'digit' to: int digit = (int)x - (int)y; because it's more natural for this scenario.
|
On February 13 2013 07:43 darkness wrote:Show nested quote +On February 13 2013 05:32 supereddie wrote:On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: double value = a / b; let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8  Something like double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc. Awesome. This code only needs slight modification to make it work though. Math.Truncate = trunc in C Math.Pow = pow in C But yeah, this is irrelevant.  Thanks. Edit: Actually, it seems I've forgotten to say it's for C, but yeah... it's obvious how to fix this.  Edit 2: You may also want to change 'digit' to: int digit = (int)x - (int)y; because it's more natural for this scenario. That's a lot more complicated than it needs to be:
int(value * pow(10, decimalnumber)) % 10
2.283214570 * 100 => 228.3214570 cast to int => 228 228 mod 10 => 8
Edit: Forgot to include "value" in the above :-/
|
On February 13 2013 03:13 Shenghi wrote:Show nested quote +On February 13 2013 02:28 Snuggles wrote:Well I just started learning about classes and objects in Python... And it's not going so well. For some reason I just do not understand objects through and through. I feel like there's something fundamentally wrong with my way of thinking about it. For the past two days I've been tackling a bunch of "simple" problems. We pretty much went from lists to classes/objects and this stuff is just flying over my head compared to previous lessons. I'm about to head down to the remedial hall to get some help tomorrow because if I can't figure this out on my own after two days then this is a problem... Before that I was hoping I could come here and ask for your advice on it. Here's the sort of problem I'm dealing with. Problem (from myProgrammingLab for those of you who are familiar) + Show Spoiler +Write the definition of a class Player containing: An instance variable name of type String , initialized to the empty String. An instance variable score of type int , initialized to zero. A method called set_name that has one parameter, whose value it assigns to the instance variable name . A method called set_score that has one parameter, whose value it assigns to the instance variable score . A method called get_name that has no parameters and that returns the value of the instance variable name . A method called get_score that has no parameters and that returns the value of the instance variable score . No constructor need be defined.
Here's my code after dozens of attempts, I even tried a few more while writing this post... + Show Spoiler +class Player : def __init__ (self, name = "", score = 0): self.set_name(name) self.set_score(score) def set_name(self): name = self.set_name def set_score(self): score = self.set_score def get_name(): return name def get_score(): return score Usually the CodeLab will accept simple answers, and the lines of code they ask for is pretty elementary compared to the brain teasers the book has for its exercises so I am definitely doing something horribly wrong. The Lab keeps telling me I should "use object"... which I don't really understand. I feel like the more time I spend on this, the more confused I get about classes and objects... From my understanding the object in this class would be self, name, and score, but I feel like this should just be done with self, and have self.name = name and self.score = 0. Or of course I am just a big idiot who just needs someone to correct me, and they could probably do it in a sentences because this is probably very simple ;_; Please help. Logged 16 attempts today... my professor must be like wtf is this... This might be silly, but based on your post before my reply I would try writing the class without constructor. I know that the problem statement doesn't explicitly state that you should not write one, but the Counter problem statement does explicitly state you have to include a constructor, and the Player problem statement hints that they are looking for a solution without constructor. [Edit] Just spotted: The line name = self.set_name sets a local variable 'name' (local to the method) to point to the method set_name, which is not what you want. What you're looking for is something like this: def set_name(self, name): self.name = name
In your get_xxx methods, you aren't returning an instance variable (self.xxx), but either a local or global variable (depending on which one exists) which Python obviously can't find, because none exists.
Thanks for catching those, that helped for the other problems I did. I still can't get the correct code for that one problem though. But I'm just gonna go to the extra help session. I flew through the exercises (which are ridiculously harder) and the rest of the Code Lab without a problem, so that's a good sign that I just don't get what the CodeLab wants from me on that one question =_=. All that meddling with classes and objects was really good practice, I have a real good idea of how they work now. Still I can only imagine how much more complicated it could get.
|
On February 13 2013 02:40 Snuggles wrote:No it wants me to write out the Class, not use it. At some point I remember getting some feedback showing the input, how it runs through my methods. Here's the problem before that one that I managed to get right. Problem + Show Spoiler +Write the definition of a class Counter containing: An instance variable named counter of type int . A constructor that takes one int argument and assigns its value to counter A method named increment that adds one to counter . It does not take parameters or return a value. A method named decrement that subtracts one from counter . It also does not take parameters or return a value. A method named get_value that returns the value of the instance variable counter .
Answer + Show Spoiler +class Counter: def __init__(self): self.counter = 0 def increment(self): self.counter += 1 def decrement(self): self.counter -= 1 def get_value (self): return self.counter They took that one in real easily. I really don't know where the hell I messed up in the Player problem...
Actually the __init__ should be something like:
def __init__(self, counter): self.counter = counter
|
On February 12 2013 10:28 CecilSunkure wrote:Show nested quote +On February 12 2013 10:19 darkness wrote:So I have this little problem to solve: You are in charge of recording marks for a group of students. Input a list of marks. Input ends with 0 (0 itself is not someone's mark). Output the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60. Sample Input 88 71 68 70 59 81 91 42 66 77 83 0 I just need a hint how to get input like this in C. Also, how should I go about storing marks? Is this a dynamic memory (heap) matter? I already know about getchar and scanf, but are they enough? Maybe getchar() and putchar()? Please don't bother to give me the solution. I just need a little help.  Thanks. How are you supposed to store these inputs? That's the real question. You can just use scanf -it's perfect for this.
There's no need to really store the list of inputs. You just need to read one at a time and update the appropriate category.
|
On February 13 2013 04:25 enigmaticcam wrote: Anyone here have any experience in .NET with hostname resolution via proxy servers?
Basically, the jackasses in our network team decided it's a security risk for any computer on the network to resolve an internet hostname to an ip address, unless by means of the proxy server. This poses a problem for one of our existing custom apps that handles automatic FTP processes. Since it connects to a remote FTP server by hostname, it no longer works. We've sidestepped the issue temporarily by adding the host names directly to the server's hosts file, but this obviously is not a good solution in the long term.
I did some googling and couldn't really find anything. I need to be able to resolve an internet hostname to an ip address, the caveat being that I have to do it using a proxy server. Any help would really be appreciated. I can work with either VB.NET or C#.NET. Thank you!
If you want to use a proxy server, you can assign the default proxy to your web request or something simililar. Maybe it is also possible to set the proxy for your code that makes the FTP connection.
We had a similar problem where we could not connect to a old asmx webservice because we didn't use the system proxy. Now we have this code in the client to connect to the webservice (ws variable):
// Make sure that webservice calls can pass through intranet proxy ws.Credentials = CredentialCache.DefaultCredentials; ws.Proxy = WebRequest.DefaultWebProxy; if (ws.Proxy != null) ws.Proxy.Credentials = CredentialCache.DefaultCredentials;
I hope this helps, not sure if I understood your question correctly. Else you can maybe try to start up ping.exe with Process.Start() and parse the output?
|
On February 13 2013 04:25 enigmaticcam wrote: Anyone here have any experience in .NET with hostname resolution via proxy servers?
Basically, the jackasses in our network team decided it's a security risk for any computer on the network to resolve an internet hostname to an ip address, unless by means of the proxy server. This poses a problem for one of our existing custom apps that handles automatic FTP processes. Since it connects to a remote FTP server by hostname, it no longer works. We've sidestepped the issue temporarily by adding the host names directly to the server's hosts file, but this obviously is not a good solution in the long term.
I did some googling and couldn't really find anything. I need to be able to resolve an internet hostname to an ip address, the caveat being that I have to do it using a proxy server. Any help would really be appreciated. I can work with either VB.NET or C#.NET. Thank you! Setup your local DHCP server to advertise your proxy as the DNS server ? I guess this would be the best (thus thats in the hand of your network team) especially since that's a way of enforcing the fact that name resolution should go through your proxy. If instead they want the traffic to go through that proxy to another dns server then what's hinted above should help.
|
On February 13 2013 13:10 AmericanUmlaut wrote:Show nested quote +On February 13 2013 07:43 darkness wrote:On February 13 2013 05:32 supereddie wrote:On February 13 2013 04:18 darkness wrote:Hey guys, thanks for helping me last time. I have another thing that I struggle with. Say you have a double variable with this value: double value = a / b; let's say 'value = 2.283214570' after division 'a' and 'b' are both integers. Now, my problem is that I need to print the n-th digit of this double variable. E.g. n = 2 Then output would be '8' because it's the 2nd digit after decimal point. I've thought about double -> string, but my implementation doesn't work for integers that are up to 60000 which is a requirement. Just use math? Multiply 'value' with 10^decimalnumber (so you have 228.3214570). Take the int part of it (=228). Do it again with decimalnumber - 1 and take int part: 22. Multiply by 10 = 220. Then just substract the two: 228 - 220 = 8  Something like double value = a / b; // 2.283214570 double x = Math.Truncate(value * Math.Pow(10, decimalnumber)); // 228 double y = Math.Truncate(value * Math.Pow(10, decimalnumber - 1)) * 10; // 220 double digit = x - y; // 228 - 220 = 8;
Be careful about overflows etc. Awesome. This code only needs slight modification to make it work though. Math.Truncate = trunc in C Math.Pow = pow in C But yeah, this is irrelevant.  Thanks. Edit: Actually, it seems I've forgotten to say it's for C, but yeah... it's obvious how to fix this.  Edit 2: You may also want to change 'digit' to: int digit = (int)x - (int)y; because it's more natural for this scenario. That's a lot more complicated than it needs to be: int(value * pow(10, decimalnumber)) % 10
2.283214570 * 100 => 228.3214570 cast to int => 228 228 mod 10 => 8 Edit: Forgot to include "value" in the above :-/ Doh, ofcourse! How could I forget about the mod operator 
|
|
|
|
|
|