# qb64 feature list (*url)

mennonite
mennonite

Galleon
Galleon
99% right!
I noticed a couple of incorrect colors but I think I'll wait till Demo #5 is released before fixing this up. Thanks for providing a good reference everyone can have fun using.

Galleon
Galleon
CINT/CLNG/CSNG/CDBL/INT/FIX/_ROUND
OPTION BASE
CSRLIN
DATE\$ (both function & statement implemented)
TIME\$ (both function & statement implemented)
TAN
ATN
LOG
EXP

Of course, that's just what's been coded over the past few days, Demo #5 has so much more!

PS. _ROUND rounds numbers to integers as appose to CINT which rounds numbers to INTEGERs. Make sense? Anyway _ROUND is faster and works on a much wider range of numbers (it can return signed or unsigned INTEGER64 values) but provides no overflow checking.

I'm just curious as to which rounding algorithm you used. as you might have read in Moneo's rounding tutorial there's more than one way to round a number .

The way you describe _ROUND here seems to be a 64bit replacement for the CINT() or INT() functions would round allow to say round to 2 decimal places for example? or does it always round to the nearest integer value. I assume the latter since you said it returns a 64 bit signed or unsigned integer. . Perhaps a rounding function that allows to define the number of decimal places to round to might be fun. .

Just a suggestion hehe.

rpgfan3233
rpgfan3233
I like my rounding method, which implements symmetric arithmetic rounding (aka "round-half-up"):
DEF FNround(x) = FIX(x + 0.5 * SGN(x))
or
DEF FNround(x) = INT(x + 0.5 * SGN(x))

In some typical C code:
#define ROUND(x) ((int)(x + 0.5 * ((x < 0) ? -1 : 1)))

Yeah, functions are better (they have type-checking and such), but the macro and DEF FN was simplest. Shoot me. Err... No, wait! SUE ME! SUE ME! *the MPAA comes in* Aww, man!

unsigned int n = 0xffffffffUL;
printf("I have %u pirated movies.\n", ++n);
/* thank goodness for the behavior of C */

mennonite
mennonite
99% right!
I noticed a couple of incorrect colors but I think I'll wait till Demo #5 is released before fixing this up. Thanks for providing a good reference everyone can have fun using.
took a bit of research, but there were a couple i wasn't even sure about. although i tried out a lot of stuff in 3 and 4.

for demo2, there were things that were not features of demo2, but they were in the program you wrote in basic to make demo2, etc, so i assumed they were already part of qb64 by then.

mennonite
mennonite
I like my rounding method, which implements symmetric arithmetic rounding (aka "round-half-up"):
DEF FNround(x) = FIX(x + 0.5 * SGN(x))
or
DEF FNround(x) = INT(x + 0.5 * SGN(x))

In some typical C code:
#define ROUND(x) ((int)(x + 0.5 * ((x < 0) ? -1 : 1)))

Yeah, functions are better (they have type-checking and such), but the macro and DEF FN was simplest. Shoot me. Err... No, wait! SUE ME! SUE ME! *the MPAA comes in* Aww, man!

unsigned int n = 0xffffffffUL;
printf("I have %u pirated movies.\n", ++n);
/* thank goodness for the behavior of C */
*right now i just use dim a as integer, - .5 from a and it's like int(a) for a > 0

mennonite
mennonite
'public domain

here's locate:
locate y
locate y,x
locate ,x
locate y,x,v

here's roundnum:
round(n)
round(n, -1, 10)

the default, round(n) is like using round(n,0,1)

n is the numeric you're rounding, the next is -1 (up) or 1 (down) or default 0 (nearest) and the next is the nearest what- so round(n,1,100) would round 147 to 200. round(n,0,1) would work like dim n as integer, and round(n,-1,1) would be much like or exactly like int(n)

mennonite
mennonite
it would actually be called roundnum() and -1 would be round down, and 1 would be round up, but other than that, yeah.

Galleon
Galleon
I'm just curious as to which rounding algorithm you used. as you might have read in Moneo's rounding tutorial there's more than one way to round a number .

The way you describe _ROUND here seems to be a 64bit replacement for the CINT() or INT() functions would round allow to say round to 2 decimal places for example? or does it always round to the nearest integer value. I assume the latter since you said it returns a 64 bit signed or unsigned integer. . Perhaps a rounding function that allows to define the number of decimal places to round to might be fun. .

Just a suggestion hehe.
The problem with CINT and CLNG is they are specific to a particular data type and also require range checks for compatibility with QBASIC. QB64 contains more data types so it was necessary to add a new function. If it were called _CINT64 then you'd expect it to return a value which is a signed 64 bit integer, however this would have been misleading because it you pass it an unsigned value it returns it as is. I also wanted a simple rounding function which would round a float to an integer value quickly and this meant skipping range checking.

How does it round?
The same way QBASIC automatically rounds floating point numbers to integers. Consider the following code.
a!=1.6
b%=a!
print b%
It prints 2. In the same way the following code...
print _ROUND(1.6)
...would also print 2.