----------------------------------- Blade Sun Mar 30, 2003 10:52 am Manipulate Integers ----------------------------------- how can you get the digits from integers... what i want to do is take a number... get the last digit, delete it then subtract it from the whole number... ----------------------------------- azndragon Sun Mar 30, 2003 11:29 am ----------------------------------- This is used with the () after calling the variable. You do this: var number : int var othernumber : string var newnumber : int put "Enter a number" get number othernumber := intstr (number) othernumber := othernumber (length (othernumber) - 1 .. length (othernumber) - 1) newnumber := strint (othernumber) number := number - newnumber put number Basically, this program converts the input into a string, takes the last letter, converts it back to an integer, and subtracts it from the original number. ----------------------------------- Blade Sun Mar 30, 2003 11:39 am ----------------------------------- yeah, thats pretty much what i did... i thought there was a way i could do it without converting it to a string... but i guess not eh.. ----------------------------------- Tony Sun Mar 30, 2003 2:00 pm ----------------------------------- well if its just the last number, you can divide the whole number by 10 then subtract same number rounded down then multiply back by 10... since the line above doesnt make sence even to myself, I'll just show you the code: lastDigit := ( (number/10) - floor(number/10) ) * 10 ----------------------------------- azndragon Sun Mar 30, 2003 2:13 pm ----------------------------------- Yeah, Tony's suggestion works well. I just don't know the shortcuts in programming, but then again, I've only been programming for about 4 months now, maybe experience allows you to learn the good shortcuts. ----------------------------------- Tony Sun Mar 30, 2003 3:37 pm ----------------------------------- well its more of being able to look at problem from different perspectives... while in azndragon's solution he used turings ablitity to turn integer into a string (which he is able to manipulate well)... I used mathimatical approach. its all about "thinking outside the box" and trying out new ways of doing things. I suppose that comes with experimenting or having a creative mind to begin with. (Note: you'll not get it unless you try it... such as experience is nothing without experimenting) ----------------------------------- azndragon Sun Mar 30, 2003 4:03 pm ----------------------------------- well its more of being able to look at problem from different perspectives... while in azndragon's solution he used turings ablitity to turn integer into a string (which he is able to manipulate well)... I used mathimatical approach. its all about "thinking outside the box" and trying out new ways of doing things. I suppose that comes with experimenting or having a creative mind to begin with. (Note: you'll not get it unless you try it... such as experience is nothing without experimenting) It's kinda ironic that I didn't take the mathematical approach, because if you know me, I'm all math (which is pretty much all programmers should be :roll: )