![]() |
![]() |
#1 |
Zone Friend
Join Date: Jan 2005
Location: italy
Age: 47
Posts: 244
|
BLITZ BASIC 2 "floor,ceiling and modulo% equivalent"
hi, there are this operators in blitz basic 2 ?
floor ? ceiling ? modulo "%" ? i cannot find in the manual unfortunately ![]() |
![]() |
![]() |
#2 |
Registered User
Join Date: Oct 2011
Location: UK
Age: 47
Posts: 304
|
I don't think you'll find anything specifically to that effect but the manual is here: http://coagulus.newport.net/t/b.pdf
If you're looking to do something 'Doomy' you might have some luck with a C2P library, Mildred is one of them. I've never used it, so can't say what it's like but there were some good examples made with one of the C2P libraries on the Blitz BUM's. |
![]() |
![]() |
#3 |
Registered User
Join Date: Nov 2010
Location: Invercargill, New Zealand
Posts: 176
|
From Blitz Basic 2 - Reference Guide-ENG.pdf available on http://amiga-manuals.xiik.net/amiga.php in eBooks category Blitz_Basic_2___ebook_ENG.rar -> 37328 KB
For floor Function: Int Syntax: Int (Expression) Modes: Amiga/Blitz Description: This returns the Integer part (before the decimal point) of Expression. Example: Code:
Print Int(23.456) ; Will simply print 23 Mod Code:
Print 10 MOD 3 ; Will print 1 Code:
PRINT (INT(23.456))+1 If you really want to use ceiling and floor you could do Code:
function ceiling{n} function return (INT(n))+1 end function Code:
function floor{n} function return INT(n) end function Last edited by Ze Emulatron; 08 June 2014 at 07:45. |
![]() |
![]() |
#4 | |
Zone Friend
Join Date: Jan 2005
Location: italy
Age: 47
Posts: 244
|
Quote:
![]() (and thanks leathered for the sprite trick in the other thread ![]() |
|
![]() |
![]() |
#5 | |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,047
|
Quote:
These should do: Code:
function ceiling{n} i = abs(int(n)) f = abs(n) - i if f = 0 then return n endif if n < 0 then return -i else return i + 1 endif end function Code:
function floor{n} i = abs(int(n)) f = abs(n) - i if f = 0 then return n endif if n < 0 then return -i - 1 else return i endif end function |
|
![]() |
![]() |
#6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,047
|
Your ceiling example doesn't work for whole numbers, either.
|
![]() |
![]() |
#7 | |
Registered User
Join Date: Nov 2010
Location: Invercargill, New Zealand
Posts: 176
|
Quote:
I adapted my code to fix those issues, I think I copied the new code correctly. Sorry about the caps, I write reserved keywords in BASIC languages in caps since using amiga basic. Code:
FUNCTION ceiling{n} IF SGN(n) = 1 AND FRAC(n) <> 0 FUNCTION RETURN (INT(n))+1 END IF FUNCTION RETURN (INT(n)) END FUNCTION Code:
FUNCTION floor{n} IF SGN(n) = -1 AND FRAC(n) <> 0 FUNCTION RETURN (INT(n))-1 END IF FUNCTION RETURN (INT(n)) END FUNCTION Last edited by Ze Emulatron; 08 June 2014 at 19:00. |
|
![]() |
![]() |
#8 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,377
|
I think the ceiling function is accomplished using QWrap().
|
![]() |
![]() |
#9 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 482
|
No, QWrap(in,min,max) does:
IF in => max THEN in=min As in : Code:
While NOT(JoyB(0)) a=QWrap (a+1,1,20) Print a," " VWait 25 Wend End 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 2 3 4 5 ... Furthermore, the difference in-max is added to min, if in exceeds max: Code:
NPrint QWrap(35,1,20) MouseWait Last edited by Cylon; 28 March 2015 at 01:21. Reason: good. |
![]() |
![]() |
#10 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,413
|
Again, just adding to this slightly old thread with another option: Use QLimit() instead of QWrap() - you give that min and max values and it gives the min value if the input is lower than the min, and the max value if the input is higher than the max. Bear in mind it only works on quick type variables so feeding it longs might give you strange results.
Also, for the modulo function there is Frac() which returns the fractional part of a number. QFrac() can be used if the input is a quick type, and will execute quicker. A full version of the original Blitz Basic 2.1 manual is available here: http://www.amiblitz.de/content/blitz...mers/0001.html |
![]() |
![]() |
#11 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 482
|
Thanks, but the whole QWrap()/QLimit() stuff is useless if you want to use faster calculations. You have to write your own WWrap()/LWrap()/LLimit() funcs and so on.
Quick types suck for advanced coding. They are nice for beginners but slow down the real sh*t. ![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Doom port where you can switch off floor and ceiling rendering | vroom6sri | support.Games | 5 | 11 February 2014 09:38 |
"DIR" equivalent to "ls |more" | Gaula92 | Coders. System | 5 | 22 September 2013 21:53 |
"Reminder "Lincs Amiga User Group aka "LAG" Meet Sat 5th of January 2013" | rockape | News | 4 | 30 January 2013 00:06 |
CD32 Image-Name-Bug: "...(bla)[!].zip" -> "...(bla)[" / "...[test].zip" -> "...[tes" | cfTrio | support.WinUAE | 8 | 18 December 2012 16:31 |
Can I access cf/sd-pcmcia with a "basic" WB3.0 floppy? | emuola | New to Emulation or Amiga scene | 7 | 12 August 2009 07:09 |
|
|