# Qbasicnews.com

Full Version: Shortest useful program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Quote:
ak00ma Wrote:... Here's a better round function... ( I only changed one thing )
Code:
`DEF FNround# (m#, dec%) = SGN(m#) * INT(10^dec% * ABS(m#) + .5) / 10 ^ dec%`
AK00MA:
Excellent, although you didn't declare what feature you added. I assume from the code that dec% declares the number of IMPLIED decimals contained in the number in m#. If this is the case, then you enhanced Oracle's general purpose function with this added feature.
*****

Oh...sorry..I forgot it. Yeah, you're right..
I've got a 3 line function that does that in the WIKI, I may just change it if one line will do.
Here's a little function of common usage:
Code:
```' ============================ FILLSTRING ================================= ' Converts value (V#) to string of specified length (L) with leading zeros. ' ========================================================================= FUNCTION FillString\$ (V#,L) STATIC    FILLSTRING\$=right\$(STRING\$(L,"0")+LTRIM\$(STR\$(V#)),L) END FUNCTION```
*****
whitetiger, just so you know: Both the NAND and NOR functions will always produce the same result.

So "X NAND Y = X NOR Y".
Truth tables

NAND
0 0 1
0 1 1
1 0 1
1 1 0

NOR
0 0 1
0 1 0
1 0 0
1 1 0

umm.
Quote:whitetiger, just so you know: Both the NAND and NOR functions will always produce the same result.

So "X NAND Y = X NOR Y".

Sorry, Progger, that's not true. If it were, why would they bother having both operators?

A NAND is the same as an AND, but reversing the bits (NOT) on the output.

A NOR is the same as an OR, but reversing the bits (NOT) on the output.

Since AND and OR are different, then NAND and NOR are different.
*****
heres a 5 line arcade style game.

Code:
```DO a=a+1 IF a>10 THEN a=0 PRINT "Final hardcore scores of yours = "; a LOOP UNTIL INKEY\$ <> ""```

To make it more fun, play it with friends, and the one with the lowest score loses a finger. Trust me, very exciting. Or you could just implement a dare system.
You should get it to print only when someone presses a key
Here you go:

Code:
```INPUT "Pick a number between 1 and 65,535: ", port& OUT port&, INT(RND * 256) PRINT "Port "; port&; " successfully f*cked up."```
Seph,
the title of this thread is the shortest useful program. The annoying programs were another thread.
Pages: 1 2 3 4 5