Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-25-2009, 07:26 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
limit(value, min, max)

Make it a hard-coded function already regardless of how easy it is to script the function.

PHP Code:
function limit(valminmax) {
  return (
val min min : (val max max val));

__________________
Quote:
Reply With Quote
  #2  
Old 08-25-2009, 07:38 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
I'd also like to see floor and ceil as run-time optimized functions.

And I've never seen this function in any other programming language, where'd you get it from?
Reply With Quote
  #3  
Old 08-25-2009, 08:17 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by WhiteDragon View Post
I'd also like to see floor and ceil as run-time optimized functions.

Posted about floor and ceil in the code gallery a few months back:

http://forums.graalonline.com/forums...ad.php?t=85605
Reply With Quote
  #4  
Old 08-25-2009, 08:18 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well I'm not entirely sure if limit is the right name for it but that's how I always thought of it.

I found it first in Zodiac's initial code by Yen, it looked something like this.

PHP Code:
function limit(valminmax) {
  if (
val min) return min;
  else if (
val max) return max;
  else return 
val;

But it's come in handy for me when I am validating quantities i.e:

temp.donation = limit(temp.value, 0, player.rupees)

Or other statistic related code.
__________________
Quote:
Reply With Quote
  #5  
Old 08-25-2009, 08:39 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Gambet View Post
Posted about floor and ceil in the code gallery a few months back:

http://forums.graalonline.com/forums...ad.php?t=85605
Yeah, I saw your thread, just I was hoping they could be built-in by Stefan, considering you can't get very good performance from anything written in GScript2 really, and floor and ceil are used in most algorithms.
Reply With Quote
  #6  
Old 08-25-2009, 09:00 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
floor==int() in graal, I'm not sure if ceil() is used often in algorithms?
Reply With Quote
  #7  
Old 08-25-2009, 09:13 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by Stefan View Post
floor==int() in graal, I'm not sure if ceil() is used often in algorithms?
Can't hurt to add them, + the limit function as posted above
__________________
Quote:
Reply With Quote
  #8  
Old 08-25-2009, 09:49 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Stefan View Post
floor==int() in graal, I'm not sure if ceil() is used often in algorithms?
It is.
Reply With Quote
  #9  
Old 08-25-2009, 09:50 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by Stefan View Post
floor==int() in graal, I'm not sure if ceil() is used often in algorithms?
I thought int() did some weird stuff when you got into negative numbers? I recall you saying that.

I had to fake ceil() in the most recent encryption algorithm I wrote (AES/Rijndael), and I've also had to fake it for things like Boyer-Moore string searching and some things for tree structures.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.