Qbasicnews.com

Full Version: Statistical Challenge
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
Quote:
Code:
FUNCTION fct (n&)
     IF n& = 0 THEN
          c& = 1
     ELSEIF n& MOD 1 THEN
          c& = n& * fct(n& - 1)
     ELSE
          c& = 0
     END IF

     fct = c&
END FUNCTION

*peace

Meg.

The second IF branch will be never entered. n& MOD 1 is always false, as n& MOD 1 is always 0 (every number is divisible by 1, so the remaining will be always 0).
I mean, bigint and bignum can't combine.
Well maybe you two can get together and make a fast, accurate version of the lib. I've pm'ed Neo, but he is on holiday so we'll see.

Anyone working on the two functions above?
Ceil is already a function. Instead of ceil, they renamed it cint, for "Conversion to Integer."
Why can't they just make it convert.to.integer(x), I don't understand.

I'm not sure what your Ceiling, does, though.
CINT is not quite the same... It rounds numbers from 4.5 downwards down to 4, for example. I want a function that rounds, say 4.1, 4.00000001 and 4.7 up to 5 for example. It should work for negative numbers too, eg -4.5 rounds to -4.

CEILING rounds the value x up to the nearest common multiple of "significance". So when x=4 and sig=5 then x is rounded up to the nearest c.m which is 5, but when x=6 and sig=5 x is rounded up to 10, the next multiple of 5. If x=0 then the function should return 0.

Other examples:

CEILING(22, 5) returns 25
CEILING(-1, 5) returns function error (what ever error code that is)
CEILING(3,181) returns 181
*sigh*, use youre brains! if you want it to round up, add 1 and round down!

int(x) - round down
int(x + .5) - round
int (x + 1) - round up
Like I said, there may have been a function that already did that. Thanks anyway.

Code:
FUNCTION RoundUp (x)
' This function rounds a number up to the nearest whole integer.
' Supplied by toonski84

RoundUp = INT(x + 1)
END FUNCTION

ps: What should the result for RoundUp(0) be? 0 or 1?
What do you think???

1 of course
Anytime I use rounding up like this CEILING of yours, I get the difference, not the next number.

Code:
sub CEILING%(n%, c%)
if n% = 0 then ceiling% = 0: exit sub
ceiling% = n% - n% mod c% + c%
end sub

Why should it return 0 if x is 0? Do you have something against zero???!????!????!????!?
OK, it'll return 0.

I'll test your ceiling thingy soon.
Pages: 1 2 3 4 5 6