Ok I need to work some numbers in my code to round off (.1 - .9) numbers. Is there a predefine proc for this?
Or do I need to make some code to round off the numbers myself?
LJR
ID:150152
![]() Dec 6 2001, 12:27 pm
|
|
![]() Dec 6 2001, 12:28 pm
|
|
round()
|
LordJR wrote:
Ok I need to work some numbers in my code to round off (.1 - .9) numbers. Is there a predefine proc for this? To round to the nearest integer, use round(n,1). To round to the nearest X, use round(n,X). To cut off everything after the decimal point and just use the integer part of a number (not the same as rounding), use round(n) with no second argument. Lummox JR |
Thanks guys!! I figure there would be something to make it easier! ;)
YAY! Now I can make it so people only loose 1/3 of their gold!!! And not all of it!!!.. after loosing in battle. LJR |
hmm I seem to be having problems with my code.
mob/pc Login() var/A, B A = 9 B = A/2 round(B,1) (line 21) usr << B This gives me this on the compile dm:21:round :warning: statement has no effect What do I need to change, this is just a test setup to check the code before I enter it where it needs to go in my actual project. LJR |
LordJR wrote:
hmm I seem to be having problems with my code.I finally got it to work with this code if anyone ever has the same prob. mob/pc Login() var/A, B A = 9 A = A/2 B = round(A) usr << B |
LordJR wrote:
round(B,1) (line 21)... dm:21:round :warning: statement has no effect For future reference, you get this error because DM knows round() is supposed to return a value, but you're not using the return value for anything. This statement doesn't change B; it merely calculates the round-off for you. What you need is this: B = round(B,1) Lummox JR |