Computer Science Canada Help reverse number |
Author: | con.focus [ Sun Nov 28, 2004 11:41 am ] | ||
Post subject: | Help reverse number | ||
i need to be able to in out a number and get the code to reverse in and output it on to the screen
the only problem im having ( i think is outputting it on the screen , can somone tell me wut im doing wrong ![]() |
Author: | 1337_brad [ Sun Nov 28, 2004 12:05 pm ] | ||
Post subject: | Well.. | ||
First of all, functions should not have put statements in them. A function is only for finding one value, (whether it be string, int, etc) but I think the code you want it:
|
Author: | con.focus [ Sun Nov 28, 2004 12:19 pm ] |
Post subject: | |
the only problem wit that is i need to convert it using a int , or real number not a string i know wut i had but i use intstr(n) to convert it |
Author: | Cervantes [ Sun Nov 28, 2004 12:37 pm ] | ||
Post subject: | |||
Here's a nice simple way to do it, for an integer. You can change it to have some error checking and also do for real numbers as well.
|
Author: | con.focus [ Sun Nov 28, 2004 12:58 pm ] |
Post subject: | |
thx carvantes i didnt know you could do that i thought the fucntion would have to be with the reverse Number thx alot btw wut are bits ne thing special like forum gold on different sites ??? |
Author: | Cervantes [ Sun Nov 28, 2004 2:55 pm ] |
Post subject: | |
Learn about bits Here |
Author: | con.focus [ Sun Nov 28, 2004 5:18 pm ] | ||
Post subject: | |||
im trying to modify the code to do real numbers but i keep getting an eror " Call to 'realstr' has too few parameters
wut am i doing wrong |
Author: | Cervantes [ Sun Nov 28, 2004 5:29 pm ] |
Post subject: | |
Just add a zero as your second parameter for the realstr function. The Turing Reference wrote: Syntax realstr ( r : real, width : int ) : string Description The realstr function is used to convert a real number to a string. For example, realstr (2.5e1, 4)="bb25" where b represents a blank. The string is an approximation to r, padded on the left with blanks as necessary to a length of width. The width parameter must be non-negative. If the width parameter is not large enough to represent the value of r it is implicitly increased as needed. The displayed value is rounded to the nearest decimal equivalent with this accuracy. In the case of a tie, the display value is rounded to the next larger value. So, putting a 0 for your width will ensure that your all of your real number is changed to a string, but that it is not padded (if it was, you wouldn't be able to convert it back to a real number later). |
Author: | con.focus [ Sun Nov 28, 2004 5:49 pm ] | ||
Post subject: | |||
im reall sure where u mean to put the zero
|
Author: | Cervantes [ Sun Nov 28, 2004 5:54 pm ] | ||
Post subject: | |||
Yep, you've got it ![]()
Heh, you could have simply tried it to see what would happen. ![]() |
Author: | con.focus [ Sun Nov 28, 2004 6:22 pm ] |
Post subject: | |
thx alot it not much but i giving u my bits |
Author: | Cervantes [ Sun Nov 28, 2004 7:37 pm ] |
Post subject: | |
Heh, I appreciate your gift, though, being a mod, my bits are locked at 1000. A warm thanks is all the gratification I need. ![]() |
Author: | con.focus [ Sun Nov 28, 2004 9:17 pm ] |
Post subject: | |
o lol thx though |