aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flsupport.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-28 04:37:42 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-28 04:37:42 +0000
commit562dcc336797951b2a8707413aa44177484c9f2a (patch)
tree162adc736d99b6edf4c03e50061831006ac0f5c4 /externals/grill/flext/source/flsupport.cpp
parent7b0d76e0a6c7b58f6a7a373755c46bde52ebea79 (diff)
""
svn path=/trunk/; revision=309
Diffstat (limited to 'externals/grill/flext/source/flsupport.cpp')
-rw-r--r--externals/grill/flext/source/flsupport.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 85ebae79..cd57dfd8 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -58,3 +58,21 @@ void flext::GetAString(const t_atom &a,char *buf,int szbuf)
else if(IsInt(a)) sprintf(buf,"%i",GetInt(a));
#endif
}
+
+int flext::FoldBits(unsigned long h,int bits)
+{
+ if(!bits) return 0;
+ const int hmax = (1<<bits)-1;
+ int ret = 0;
+ for(int i = 0; i < sizeof(h)*8; i += bits)
+ ret = ret^((h>>i)&hmax);
+ return ret;
+}
+
+int flext::Int2Bits(unsigned long n)
+{
+ int b;
+ for(b = 0; n; ++b) n >>= 1;
+ return b;
+}
+