qb64 feature list (*url)

mennonite
mennonite

January 9th, 2008, 5:57 am #1

Quote
Share

Galleon
Galleon

January 9th, 2008, 10:40 am #2

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.
Quote
Share

Galleon
Galleon

January 9th, 2008, 10:46 am #3

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.
Quote
Share

MystikShadows
MystikShadows

January 9th, 2008, 11:43 am #4

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.

Quote
Share

rpgfan3233
rpgfan3233

January 9th, 2008, 2:44 pm #5

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 */
Quote
Share

mennonite
mennonite

January 9th, 2008, 4:37 pm #6

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.
Quote
Share

mennonite
mennonite

January 9th, 2008, 4:41 pm #7

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
Quote
Share

mennonite
mennonite

January 9th, 2008, 4:49 pm #8

'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)
Quote
Share

mennonite
mennonite

January 9th, 2008, 4:50 pm #9

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

Galleon
Galleon

January 9th, 2008, 11:56 pm #10

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.

What about other rounding methods?
I really like the idea of extending the _ROUND function or perhaps making a different function which can round using a variety/combination of rules.
The rules I see as important are:
1. The direction it rounds positive and negative numbers
2. How many decimal places it rounds the number to
3. The decimal fraction which is the pivot point around which a rounding decision would be made (typically 0.5) or indeed if there is no pivot point and it always rounds up/down.
4. How it rounds a number ending with the pivot point fraction.
Consider the following...
a%=0.5
a%=0.51
a%=0.59
The 4th rule above would make a big difference to the number a% becomes
If anyone can come up with a really simple function format which could do all of the above I'm sure I'd find a way to include it.
Quote
Share