--- C:/Users/GHOSTDEATH/Desktop/userpoints/userpoints.module	Tue Feb 01 00:36:39 2011
+++ C:/Users/GHOSTDEATH/Desktop/userpoints-new/userpoints.module	Tue Feb 01 13:03:13 2011
@@ -34,6 +34,8 @@
 define('USERPOINTS_REPORT_LIMIT', 'userpoints_report_limit');
 define('USERPOINTS_REPORT_DISPLAYZERO', 'userpoints_report_displayzero');
 
+define('USERPOINTS_PRECISION_NUM', 'userpoints_precision_num');
+
 define('USERPOINTS_CATEGORY_NAME', 'Userpoints');
 define('USERPOINTS_CATEGORY_DEFAULT_VID', 'userpoints_category_default_vid');
 define('USERPOINTS_CATEGORY_DEFAULT_TID', 'userpoints_category_default_tid');
@@ -462,6 +464,23 @@
     '#default_value' => variable_get(USERPOINTS_TRANSACTION_TIMESTAMP, 1),
     '#description'   => t('Sets if the transaction timestamp should obey current time, or can be modified by the API operations. Unchecking this option will allow customization of timetamp for the transactions.'),
   );
+  
+  $group = "precision";
+  $form[$group] = array(
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#title' => t('Precision'),
+    '#description' => t(''),
+  );
+
+  $form[$group][USERPOINTS_PRECISION_NUM] = array(
+    '#type' => 'textfield',
+    '#title' => t('Number of decimals to use when displaying and calculating !points', userpoints_translation()),
+    '#default_value' => variable_get(USERPOINTS_PRECISION_NUM, 2),
+    '#size' => 2,
+    '#maxlength' => 2,
+  );
 
   $form['setting'] = module_invoke_all('userpoints', 'setting');
   return system_settings_form($form);
@@ -481,9 +500,9 @@
     $tid = userpoints_get_default_tid();
   }
   elseif ($tid == 'all') {
-    return (int)db_result(db_query('SELECT SUM(points) FROM {userpoints} WHERE uid = %d', $uid));
+    return (float)db_result(db_query('SELECT SUM(points) FROM {userpoints} WHERE uid = %d', $uid));
   }
-  return (int)db_result(db_query('SELECT points FROM {userpoints} WHERE uid = %d AND tid = %d', $uid, $tid));
+  return (float)db_result(db_query('SELECT points FROM {userpoints} WHERE uid = %d AND tid = %d', $uid, $tid));
 }
 
 /**
@@ -527,7 +546,7 @@
  * @param $params(array) or (int)
  *    if (int) assumed to be points for current user
  *    Accepts an array of keyed variables and parameters
- *    'points' => # of points (int) (required)
+ *    'points' => # of points (float) (required)
  *    'moderate' => TRUE/FALSE
  *    'uid' => $user->uid
  *    'time_stamp' => unix time of the points assignement date
@@ -776,19 +795,19 @@
   }
 
   // Calculate the current points based upon the tid
-  $current_points = (int)$params['points'] + userpoints_get_current_points($params['uid'], $params['tid']);
+  $current_points = (float)$params['points'] + userpoints_get_current_points($params['uid'], $params['tid']);
   //Grab the user's maximum points to preserve it
   $max_points = db_result(db_query('SELECT max_points FROM {userpoints} WHERE uid = %d AND tid = %d',
     $params['uid'], $params['tid']));
   if ($params['points'] > 0) {
     //points are greater than zero, update their max_points
-    $max_points = (int)$params['points'] + (int)$max_points;
+    $max_points = (float)$params['points'] + (float)$max_points;
   }
 
   // insert or update the userpoints caching table with the user's current points
   if (_userpoints_user_exists($params['uid'], $params['tid'])) {
     db_query("UPDATE {userpoints}
-              SET points = %d, max_points = %d, last_update = %d
+              SET points = %f, max_points = %f, last_update = %d
               WHERE uid = %d AND tid = %d",
               $current_points,
               $max_points,
@@ -800,7 +819,7 @@
   else {
     $result = db_query("INSERT INTO {userpoints}
       (uid, points, max_points, last_update, tid)
-      VALUES (%d, %d, %d, %d, %d )",
+      VALUES (%d, %f, %f, %d, %d )",
       $params['uid'],
       $current_points,
       $max_points,
@@ -1700,7 +1719,7 @@
   $args['approved_total'] = $grand_total;
 
   //Grab the unmoderated point total
-  $args['unapproved_total'] = (int)db_result(db_query("SELECT SUM(points) FROM {userpoints_txn} WHERE uid = %d AND status = 1", $uid));
+  $args['unapproved_total'] = (float)db_result(db_query("SELECT SUM(points) FROM {userpoints_txn} WHERE uid = %d AND status = 1", $uid));
   $args['overall_total'] = ($args['approved_total'] + $args['unapproved_total']);
 
   $header = array(
