|
Post by andrian on Dec 22, 2008 16:00:40 GMT -5
Could we please have floor and ceiling rounding? I know our regular int() already floors, but I think it would be better if that function just rounded to the nearest integer instead of flooring.
For those of you unclear about my terminology, flooring means to always round down to the nearest integer, thus 2.9999 becomes 2. Ceiling rounding always rounds up, so 2.43 becomes 3. and of course, regular rounding goes to the nearest integer, making 2.5 into 3 and 2.4 into 2.
|
|
|
Post by Nicky Peter Hollyoake on Dec 22, 2008 16:10:08 GMT -5
Function Rounding (__f#) if (__f# - INT(__f#)) >= 0.5 Then Return INT(__f# + 1) Endif Return INT(__f#) EndFunction
Function CeilingRounding(__f#) Return INT(__f# + 1) EndFunction - Nicky
|
|
|
Post by Supermonkey on Dec 22, 2008 17:01:10 GMT -5
Didn't know int always rounded down... Also nicky whats with the underscores in the parameters? is that to distinguish parameters from global/local vars?
|
|
|
Post by Nicky Peter Hollyoake on Dec 22, 2008 17:06:34 GMT -5
Didn't know int always rounded down... Also nicky whats with the underscores in the parameters? is that to distinguish parameters from global/local vars? Yes. - Nicky
|
|
|
Post by smc44 on Dec 22, 2008 17:51:37 GMT -5
i really like that style its very helpful when organzing your code
|
|
|
Post by Empyrion Martyr on Dec 22, 2008 19:17:12 GMT -5
Just be careful when doing that underscore thingie in c++, usually undescored vars are reserved for the inner workings of some obscure include files. Should be no problem in most cases, but there's a convention stating that a variable looking like that is mostly a system var and shouldn't be touched (well, most of the time, but rules are broken often ). Other than that, it's ok.
|
|
|
Post by Supermonkey on Dec 23, 2008 14:11:05 GMT -5
That's surely not a problem with namespaces? Isn't that what they're there for? I don't have those worries with good old C#, in fact I prefix all private fields in a class with a single underscore.
|
|
|
Post by Empyrion Martyr on Dec 24, 2008 20:40:21 GMT -5
If you know what you're doing and the conventions, then it's no problem. The "private parts" of a class are sometimes considered "system stuff" anyway, so it's fine.
|
|