 core/includes/bootstrap.inc                        |  63 ++++++++---
 core/includes/common.inc                           | 115 +++++++++++++--------
 core/includes/file.inc                             |   6 +-
 core/modules/color/color.module                    |  35 +++----
 core/modules/file/file.field.inc                   |  20 ++--
 core/modules/file/file.module                      |  10 +-
 .../Drupal/file/Tests/FileFieldValidateTest.php    |  24 ++---
 .../lib/Drupal/file/Tests/FileTokenReplaceTest.php |   4 +-
 .../file/lib/Drupal/file/Tests/ValidatorTest.php   |   4 +-
 core/modules/image/image.field.inc                 |   2 +-
 .../Drupal/image/Tests/ImageFieldDisplayTest.php   |   4 +-
 .../lib/Drupal/simpletest/WebTestBase.php          |   2 +-
 core/modules/simpletest/simpletest.install         |   5 +-
 .../Drupal/system/Tests/Bootstrap/MiscUnitTest.php |  13 +--
 .../{SizeUnitTest.php => ByteCountUnitTest.php}    |  97 +++++++++++------
 .../Tests/Upgrade/UserPictureUpgradePathTest.php   |   2 +-
 core/modules/system/system.install                 |   8 +-
 core/modules/system/system.tokens.inc              |   2 +-
 core/modules/user/user.install                     |   4 +-
 .../Drupal/views/Plugin/views/field/FileSize.php   |   4 +-
 .../views/Tests/Handler/FieldFileSizeTest.php      |   6 +-
 .../lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php |   2 +-
 .../tests/modules/xmlrpc_test/xmlrpc_test.module   |   6 +-
 23 files changed, 257 insertions(+), 181 deletions(-)
 rename core/modules/system/lib/Drupal/system/Tests/Common/{SizeUnitTest.php => ByteCountUnitTest.php} (41%)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 7dc75f5..7612428 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -44,7 +44,7 @@
 /**
  * Minimum recommended value of PHP memory_limit.
  */
-const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT = '32M';
+const DRUPAL_MINIMUM_PHP_MEMORY_LIMIT = '32 MiB';
 
 /**
  * Error reporting level: display no errors.
@@ -183,9 +183,16 @@
 /**
  * The number of bytes in a kilobyte.
  *
- * For more information, visit http://en.wikipedia.org/wiki/Kilobyte.
+ * See http://en.wikipedia.org/wiki/Kilobyte for more information.
  */
-const DRUPAL_KILOBYTE = 1024;
+const DRUPAL_KILOBYTE = 1000;
+
+/**
+ * The number of bytes in a kibibyte.
+ *
+ * See http://en.wikipedia.org/wiki/Kibibyte for more information.
+ */
+const DRUPAL_KIBIBYTE = 1024;
 
 /**
  * Special system language code (only applicable to UI language).
@@ -3227,33 +3234,57 @@ function _drupal_shutdown_function() {
 }
 
 /**
+ * Returns the maximum amount of memory in bytes that Drupal is allowed to
+ * allocate.
+ *
+ * @return
+ *   The number of bytes, or NULL if there is no limit.
+ */
+function drupal_memory_limit() {
+  $memory_limit = ini_get('memory_limit');
+
+  // If memory_limit is -1, there is no limit.
+  if ($memory_limit == -1) {
+    return NULL;
+  }
+
+  // Force parsing of PHP memory_limit as IEC, see
+  // http://php.net/manual/en/faq.using.php#faq.using.shorthandbytes
+  return parse_byte_count($memory_limit, TRUE);
+}
+
+/**
  * Compares the memory required for an operation to the available memory.
  *
  * @param $required
  *   The memory required for the operation, expressed as a number of bytes with
- *   optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8bytes,
- *   9mbytes).
+ *   optional SI or IEC binary unit prefix (e.g. 2, 3 K, 5MB, 10 G, 6GiB, 8
+ *   bytes, 9mbytes).
  * @param $memory_limit
  *   (optional) The memory limit for the operation, expressed as a number of
- *   bytes with optional SI or IEC binary unit prefix (e.g. 2, 3K, 5MB, 10G,
- *   6GiB, 8bytes, 9mbytes). If no value is passed, the current PHP
- *   memory_limit will be used. Defaults to NULL.
+ *   bytes with optional SI or IEC binary unit prefix. If no value is passed,
+ *   the current PHP memory_limit will be used. Defaults to NULL.
  *
  * @return
  *   TRUE if there is sufficient memory to allow the operation, or FALSE
  *   otherwise.
  */
 function drupal_check_memory_limit($required, $memory_limit = NULL) {
-  if (!isset($memory_limit)) {
-    $memory_limit = ini_get('memory_limit');
+  if (is_null($memory_limit)) {
+    // Get PHP's memory limit.
+    $memory_limit_bytes = drupal_memory_limit();
+    // Is it unlimited?
+    if (is_null($memory_limit_bytes)) {
+      return TRUE;
+    }
+  }
+  else {
+    $memory_limit_bytes = parse_byte_count($memory_limit);
   }
 
-  // There is sufficient memory if:
-  // - No memory limit is set.
-  // - The memory limit is set to unlimited (-1).
-  // - The memory limit is greater than or equal to the memory required for
-  //   the operation.
-  return ((!$memory_limit) || ($memory_limit == -1) || (parse_size($memory_limit) >= parse_size($required)));
+  // There is sufficient memory if the memory limit is greater than or equal to
+  // the memory required for the operation.
+  return $memory_limit_bytes >= parse_byte_count($required);
 }
 
 /**
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 5e8e2d1..27e72cd 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -1414,65 +1414,92 @@ function format_plural($count, $singular, $plural, array $args = array(), array
 }
 
 /**
- * Parses a given byte count.
+ * Parses a human-readable representation of a byte count.
  *
- * @param $size
- *   A size expressed as a number of bytes with optional SI or IEC binary unit
- *   prefix (e.g. 2, 3K, 5MB, 10G, 6GiB, 8 bytes, 9mbytes).
+ * See http://en.wikipedia.org/wiki/Binary_prefix for more information.
+ *
+ * @param $count
+ *   A byte count expressed as a numeric quantity, optionally followed by a
+ *   unit:
+ *    - SI (powers of 1000), e.g. 7.4kB, 8 MB, 42.9 megabytes, 9 G, 1terabyte.
+ *    - IEC (powers of 1024), e.g. 9 Kibibytes, 0.3 MiB, 40gibibytes.
+ * @param $force_iec
+ *   Override the unit type detection to be IEC. Defaults to FALSE.
  *
  * @return
- *   An integer representation of the size in bytes.
- */
-function parse_size($size) {
-  $unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
-  $size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
-  if ($unit) {
-    // Find the position of the unit in the ordered string which is the power of magnitude to multiply a kilobyte by.
-    return round($size * pow(DRUPAL_KILOBYTE, stripos('bkmgtpezy', $unit[0])));
-  }
-  else {
-    return round($size);
+ *   An integer representation of the byte count.
+ *
+ * @see format_byte_count()
+ */
+function parse_byte_count($count, $force_iec = FALSE) {
+  // Break up the count into quantity and unit.
+  preg_match('/([0-9.]+)[ ]*([a-z]*)/', strtolower($count), $matches);
+
+  $quantity = $matches[1];
+  $unit = $matches[2];
+  $unit_length = strlen($unit);
+
+  if ($unit_length > 0) {
+    // Determine if the unit is SI or IEC. The second letter of an abbreviated
+    // IEC unit is always 'i', e.g. Mi or MiB. The forth letter of an
+    // unabbreviated IEC unit is always 'i', e.g. mebibyte.
+    if ((($unit_length == 2 || $unit_length == 3) && $unit[1] == 'i') ||
+      ($unit_length >= 4 && $unit[3] == 'i') || $force_iec)
+    {
+      $base = DRUPAL_KIBIBYTE;
+    }
+    else {
+      $base = DRUPAL_KILOBYTE;
+    }
+
+    // Multiply the quantity by the quantity of the unit. The quantity of the
+    // unit is calculated by determining its order of magnitude and raising the
+    // base of the unit to this power. If the unit is missing, strpos() returns
+    // FALSE which is cast to 0. This causes the unit to default to 'b'.
+    $quantity *= pow($base, (int) strpos('bkmgtpezy', $unit[0]));
   }
+
+  // Make sure an integer is returned. Not cast to an integer type as this would
+  // limit the maximum to 2 GiB on 32-bit platforms.
+  return floor($quantity);
 }
 
 /**
- * Generates a string representation for the given byte count.
+ * Formats a byte count into a human-readable representation.
  *
- * @param $size
- *   A size in bytes.
- * @param $langcode
- *   Optional language code to translate to a language other than what is used
- *   to display the page.
+ * See http://en.wikipedia.org/wiki/Binary_prefix for more information.
+ *
+ * @param $count
+ *   An integer byte count.
+ * @param $iec
+ *   Format as IEC instead of SI. Defaults to FALSE.
  *
  * @return
- *   A translated string representation of the size.
+ *   A human readable representation of the byte count, e.g.
+ *    - SI (powers of 1000) 7.4 kB, 8 MB, 42.9 MB, 9 GB, 1 TB.
+ *    - IEC (powers of 1024) 9 KiB, 0.3 MiB, 40 GiB.
+ *
+ * @see parse_byte_count()
  */
-function format_size($size, $langcode = NULL) {
-  if ($size < DRUPAL_KILOBYTE) {
-    return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
+function format_byte_count($count, $iec = FALSE) {
+  if ($iec) {
+    $base = DRUPAL_KIBIBYTE;
+    $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB');
   }
   else {
-    $size = $size / DRUPAL_KILOBYTE; // Convert bytes to kilobytes.
-    $units = array(
-      t('@size KB', array(), array('langcode' => $langcode)),
-      t('@size MB', array(), array('langcode' => $langcode)),
-      t('@size GB', array(), array('langcode' => $langcode)),
-      t('@size TB', array(), array('langcode' => $langcode)),
-      t('@size PB', array(), array('langcode' => $langcode)),
-      t('@size EB', array(), array('langcode' => $langcode)),
-      t('@size ZB', array(), array('langcode' => $langcode)),
-      t('@size YB', array(), array('langcode' => $langcode)),
-    );
-    foreach ($units as $unit) {
-      if (round($size, 2) >= DRUPAL_KILOBYTE) {
-        $size = $size / DRUPAL_KILOBYTE;
-      }
-      else {
-        break;
-      }
+    $base = DRUPAL_KILOBYTE;
+    $units = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
+  }
+
+  foreach ($units as $unit) {
+    if ($count < $base) {
+      break;
     }
-    return str_replace('@size', round($size, 2), $unit);
+
+    $count /= $base;
   }
+
+  return round($count, 2) . ' ' . $unit;
 }
 
 /**
diff --git a/core/includes/file.inc b/core/includes/file.inc
index e3ac8ea..8b3ba51 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -1097,7 +1097,7 @@ function file_save_upload($source, $validators = array(), $destination = FALSE,
     switch ($uploaded_files['files']['error'][$source][$i]) {
       case UPLOAD_ERR_INI_SIZE:
       case UPLOAD_ERR_FORM_SIZE:
-        drupal_set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $name, '%maxsize' => format_size(file_upload_max_size()))), 'error');
+        drupal_set_message(t('The file %file could not be saved because it exceeds %maxsize, the maximum allowed size for uploads.', array('%file' => $name, '%maxsize' => format_byte_count(file_upload_max_size()))), 'error');
         $files[$i] = FALSE;
         continue;
 
@@ -1473,11 +1473,11 @@ function file_upload_max_size() {
 
   if ($max_size < 0) {
     // Start with post_max_size.
-    $max_size = parse_size(ini_get('post_max_size'));
+    $max_size = parse_byte_count(ini_get('post_max_size'), TRUE);
 
     // If upload_max_size is less, then reduce. Except if upload_max_size is
     // zero, which indicates no limit.
-    $upload_max = parse_size(ini_get('upload_max_filesize'));
+    $upload_max = parse_byte_count(ini_get('upload_max_filesize'), TRUE);
     if ($upload_max > 0 && $upload_max < $max_size) {
       $max_size = $upload_max;
     }
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 2203133..cbab2cf 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -317,26 +317,21 @@ function color_scheme_form_submit($form, &$form_state) {
     $palette += $info['schemes']['default']['colors'];
   }
 
-  // Make sure enough memory is available, if PHP's memory limit is compiled in.
-  if (function_exists('memory_get_usage')) {
-    // Fetch source image dimensions.
-    $source = drupal_get_path('theme', $theme) . '/' . $info['base_image'];
-    list($width, $height) = getimagesize($source);
-
-    // We need at least a copy of the source and a target buffer of the same
-    // size (both at 32bpp).
-    $required = $width * $height * 8;
-    // We intend to prevent color scheme changes if there isn't enough memory
-    // available.  memory_get_usage(TRUE) returns a more accurate number than
-    // memory_get_usage(), therefore we won't inadvertently reject a color
-    // scheme change based on a faulty memory calculation.
-    $usage = memory_get_usage(TRUE);
-    $memory_limit = ini_get('memory_limit');
-    $size = parse_size($memory_limit);
-    if (!drupal_check_memory_limit($usage + $required, $memory_limit)) {
-      drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_size($usage + $required - $size), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error');
-      return;
-    }
+  // Fetch source image dimensions.
+  $source = drupal_get_path('theme', $theme) . '/' . $info['base_image'];
+  list($width, $height) = getimagesize($source);
+
+  // We need at least a copy of the source and a target buffer of the same
+  // size (both at 32bpp).
+  $required = $width * $height * 8;
+  // We intend to prevent color scheme changes if there isn't enough memory
+  // available.  memory_get_usage(TRUE) returns a more accurate number than
+  // memory_get_usage(), therefore we won't inadvertently reject a color
+  // scheme change based on a faulty memory calculation.
+  $required += memory_get_usage(TRUE);
+  if (!drupal_check_memory_limit($required)) {
+    drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size. Check the <a href="@url">PHP documentation</a> for more information.', array('%size' => format_byte_count($required, TRUE), '@url' => 'http://www.php.net/manual/ini.core.php#ini.sect.resource-limits')), 'error');
+    return;
   }
 
   // Delete old files.
diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc
index 59d068b..e2dd347 100644
--- a/core/modules/file/file.field.inc
+++ b/core/modules/file/file.field.inc
@@ -110,7 +110,7 @@ function file_field_instance_settings_form($field, $instance) {
     '#type' => 'textfield',
     '#title' => t('Maximum upload size'),
     '#default_value' => $settings['max_filesize'],
-    '#description' => t('Enter a value like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_size(file_upload_max_size()))),
+    '#description' => t('Enter a value like "512" (bytes), "80 kB" (kilobytes) or "50 MB" (megabytes) in order to restrict the allowed file size. If left empty the file sizes will be limited only by PHP\'s maximum post and file upload sizes (current limit <strong>%limit</strong>).', array('%limit' => format_byte_count(file_upload_max_size()))),
     '#size' => 10,
     '#element_validate' => array('_file_generic_settings_max_filesize'),
     '#weight' => 5,
@@ -132,14 +132,14 @@ function file_field_instance_settings_form($field, $instance) {
  * Render API callback: Validates the maximum upload size field.
  *
  * Ensures that a size has been entered and that it can be parsed by
- * parse_size().
+ * parse_byte_count().
  *
  * This function is assigned as an #element_validate callback in
  * file_field_instance_settings_form().
  */
 function _file_generic_settings_max_filesize($element, &$form_state) {
-  if (!empty($element['#value']) && !is_numeric(parse_size($element['#value']))) {
-    form_error($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title']))));
+  if (!empty($element['#value']) && !parse_byte_count($element['#value'])) {
+    form_error($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 kB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title']))));
   }
 }
 
@@ -326,9 +326,9 @@ function file_field_displayed($item, $field) {
  */
 function file_field_widget_upload_validators($field, $instance) {
   // Cap the upload size according to the PHP limit.
-  $max_filesize = parse_size(file_upload_max_size());
-  if (!empty($instance['settings']['max_filesize']) && parse_size($instance['settings']['max_filesize']) < $max_filesize) {
-    $max_filesize = parse_size($instance['settings']['max_filesize']);
+  $max_filesize = file_upload_max_size();
+  if (!empty($instance['settings']['max_filesize']) && parse_byte_count($instance['settings']['max_filesize']) < $max_filesize) {
+    $max_filesize = parse_byte_count($instance['settings']['max_filesize']);
   }
 
   $validators = array();
@@ -654,7 +654,7 @@ function theme_file_widget($variables) {
   if (!empty($element['fids']['#value'])) {
     // Add the file size after the file name.
     $file = reset($element['#files']);
-    $element['file_' . $file->fid]['filename']['#markup'] .= ' <span class="file-size">(' . format_size($file->filesize) . ')</span> ';
+    $element['file_' . $file->fid]['filename']['#markup'] .= ' <span class="file-size">(' . format_byte_count($file->filesize) . ')</span> ';
   }
   $output .= drupal_render_children($element);
   $output .= '</div>';
@@ -791,7 +791,7 @@ function theme_file_upload_help($variables) {
     $descriptions[] = $description;
   }
   if (isset($upload_validators['file_validate_size'])) {
-    $descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_size($upload_validators['file_validate_size'][0]) . '</strong>'));
+    $descriptions[] = t('Files must be less than !size.', array('!size' => '<strong>' . format_byte_count($upload_validators['file_validate_size'][0]) . '</strong>'));
   }
   if (isset($upload_validators['file_validate_extensions'])) {
     $descriptions[] = t('Allowed file types: !extensions.', array('!extensions' => '<strong>' . check_plain($upload_validators['file_validate_extensions'][0]) . '</strong>'));
@@ -862,7 +862,7 @@ function theme_file_formatter_table($variables) {
   foreach ($variables['items'] as $delta => $item) {
     $rows[] = array(
       theme('file_link', array('file' => (object) $item)),
-      format_size($item['filesize']),
+      format_byte_count($item['filesize']),
     );
   }
 
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 18dae26..e1fa1f8 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -400,12 +400,12 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) {
   $errors = array();
 
   if ($file_limit && $file->filesize > $file_limit) {
-    $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($file->filesize), '%maxsize' => format_size($file_limit)));
+    $errors[] = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_byte_count($file->filesize), '%maxsize' => format_byte_count($file_limit)));
   }
 
   // Save a query by only calling spaceUsed() when a limit is provided.
   if ($user_limit && (Drupal::entityManager()->getStorageController('file')->spaceUsed($user->uid) + $file->filesize) > $user_limit) {
-    $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->filesize), '%quota' => format_size($user_limit)));
+    $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_byte_count($file->filesize), '%quota' => format_byte_count($user_limit)));
   }
 
   return $errors;
@@ -741,7 +741,7 @@ function file_ajax_upload() {
 
   if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
     // Invalid request.
-    drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
+    drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_byte_count(file_upload_max_size()))), 'error');
     $response = new AjaxResponse();
     return $response->addCommand(new ReplaceCommand(NULL, theme('status_messages')));
   }
@@ -803,14 +803,14 @@ function file_ajax_progress($key) {
   if ($implementation == 'uploadprogress') {
     $status = uploadprogress_get_info($key);
     if (isset($status['bytes_uploaded']) && !empty($status['bytes_total'])) {
-      $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['bytes_uploaded']), '@total' => format_size($status['bytes_total'])));
+      $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_byte_count($status['bytes_uploaded']), '@total' => format_byte_count($status['bytes_total'])));
       $progress['percentage'] = round(100 * $status['bytes_uploaded'] / $status['bytes_total']);
     }
   }
   elseif ($implementation == 'apc') {
     $status = apc_fetch('upload_' . $key);
     if (isset($status['current']) && !empty($status['total'])) {
-      $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_size($status['current']), '@total' => format_size($status['total'])));
+      $progress['message'] = t('Uploading... (@current of @total)', array('@current' => format_byte_count($status['current']), '@total' => format_byte_count($status['total'])));
       $progress['percentage'] = round(100 * $status['current'] / $status['total']);
     }
   }
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
index faceb99..60acb7b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
@@ -74,17 +74,13 @@ function testFileMaxSize() {
     $field_name = strtolower($this->randomName());
     $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
 
-    $small_file = $this->getTestFile('text', 131072); // 128KB.
-    $large_file = $this->getTestFile('text', 1310720); // 1.2MB
+    $small_file = $this->getTestFile('text', 131072);  // 128KiB
+    $large_file = $this->getTestFile('text', 1310720);  // 1.25MiB
 
     // Test uploading both a large and small file with different increments.
-    $sizes = array(
-      '1M' => 1048576,
-      '1024K' => 1048576,
-      '1048576' => 1048576,
-    );
+    $sizes = array('1M', '1000K', '1000000');
 
-    foreach ($sizes as $max_filesize => $file_limit) {
+    foreach ($sizes as $max_filesize) {
       // Set the max file upload size.
       $this->updateFileField($field_name, $type_name, array('max_filesize' => $max_filesize));
 
@@ -92,13 +88,13 @@ function testFileMaxSize() {
       $nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
       $node = node_load($nid, TRUE);
       $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
-      $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
-      $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_size($small_file->filesize), '%maxsize' => $max_filesize)));
+      $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_byte_count($small_file->filesize), '%maxsize' => $max_filesize)));
+      $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) under the max limit (%maxsize).', array('%filesize' => format_byte_count($small_file->filesize), '%maxsize' => $max_filesize)));
 
       // Check that uploading the large file fails (1M limit).
       $nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
-      $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size($large_file->filesize), '%maxsize' => format_size($file_limit)));
-      $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_size($large_file->filesize), '%maxsize' => $max_filesize)));
+      $error_message = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_byte_count($large_file->filesize), '%maxsize' => format_byte_count(parse_byte_count($max_filesize))));
+      $this->assertRaw($error_message, t('Node save failed when file (%filesize) exceeded the max upload size (%maxsize).', array('%filesize' => format_byte_count($large_file->filesize), '%maxsize' => $max_filesize)));
     }
 
     // Turn off the max filesize.
@@ -108,8 +104,8 @@ function testFileMaxSize() {
     $nid = $this->uploadNodeFile($large_file, $field_name, $type_name);
     $node = node_load($nid, TRUE);
     $node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
-    $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
-    $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
+    $this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_byte_count($large_file->filesize))));
+    $this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_byte_count($large_file->filesize))));
   }
 
   /**
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
index f8f4807..a1b2d83 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
@@ -53,7 +53,7 @@ function testFileTokenReplacement() {
     $tests['[file:name]'] = check_plain($file->filename);
     $tests['[file:path]'] = check_plain($file->uri);
     $tests['[file:mime]'] = check_plain($file->filemime);
-    $tests['[file:size]'] = format_size($file->filesize);
+    $tests['[file:size]'] = format_byte_count($file->filesize);
     $tests['[file:url]'] = check_plain(file_create_url($file->uri));
     $tests['[file:timestamp]'] = format_date($file->timestamp, 'medium', '', NULL, $language_interface->langcode);
     $tests['[file:timestamp:short]'] = format_date($file->timestamp, 'short', '', NULL, $language_interface->langcode);
@@ -72,7 +72,7 @@ function testFileTokenReplacement() {
     $tests['[file:name]'] = $file->filename;
     $tests['[file:path]'] = $file->uri;
     $tests['[file:mime]'] = $file->filemime;
-    $tests['[file:size]'] = format_size($file->filesize);
+    $tests['[file:size]'] = format_byte_count($file->filesize);
 
     foreach ($tests as $input => $expected) {
       $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->langcode, 'sanitize' => FALSE));
diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
index d8164c1..98da1e6 100644
--- a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php
@@ -136,8 +136,8 @@ function testFileValidateSize() {
     // Run these tests as a regular user.
     $user = $this->drupalCreateUser();
 
-    // Create a file with a size of 1000 bytes, and quotas of only 1 byte.
-    $file = entity_create('file', array('filesize' => 1000));
+    // Create a file with a size of 1 kB, and quotas of only 1 byte.
+    $file = entity_create('file', array('filesize' => DRUPAL_KILOBYTE));
     $errors = file_validate_size($file, 0, 0);
     $this->assertEqual(count($errors), 0, t('No limits means no errors.'), 'File');
     $errors = file_validate_size($file, 1, 0);
diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc
index a287620..97eb4f8 100644
--- a/core/modules/image/image.field.inc
+++ b/core/modules/image/image.field.inc
@@ -440,7 +440,7 @@ function theme_image_widget($variables) {
   $output .= '<div class="image-widget-data">';
   if (!empty($element['fids']['#value'])) {
     $file = reset($element['#files']);
-    $element['file_' . $file->fid]['filename']['#markup'] .= ' <span class="file-size">(' . format_size($file->filesize) . ')</span> ';
+    $element['file_' . $file->fid]['filename']['#markup'] .= ' <span class="file-size">(' . format_byte_count($file->filesize) . ')</span> ';
   }
   $output .= drupal_render_children($element);
   $output .= '</div>';
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
index c30c686..bcbed80 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
@@ -137,7 +137,7 @@ function testImageFieldSettings() {
     $instance_settings = array(
       'alt_field' => 1,
       'file_extensions' => $test_image_extension,
-      'max_filesize' => '50 KB',
+      'max_filesize' => '50 kB',
       'max_resolution' => '100x100',
       'min_resolution' => '10x10',
       'title_field' => 1,
@@ -149,7 +149,7 @@ function testImageFieldSettings() {
     $instance = $this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings);
 
     $this->drupalGet('node/add/article');
-    $this->assertText(t('Files must be less than 50 KB.'), 'Image widget max file size is displayed on article form.');
+    $this->assertText(t('Files must be less than 50 kB.'), 'Image widget max file size is displayed on article form.');
     $this->assertText(t('Allowed file types: ' . $test_image_extension . '.'), 'Image widget allowed file types displayed on article form.');
     $this->assertText(t('Images must be between 10x10 and 100x100 pixels.'), 'Image widget allowed resolution displayed on article form.');
 
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index af86db7..3376aa7 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1076,7 +1076,7 @@ protected function curlExec($curl_options, $redirect = FALSE) {
       '!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
       '@url' => isset($original_url) ? $original_url : $url,
       '@status' => $status,
-      '!length' => format_size(strlen($this->drupalGetContent()))
+      '!length' => format_byte_count(strlen($this->drupalGetContent()))
     );
     $message = t('!method @url returned @status (!length).', $message_vars);
     $this->assertTrue($this->drupalGetContent() !== FALSE, $message, t('Browser'));
diff --git a/core/modules/simpletest/simpletest.install b/core/modules/simpletest/simpletest.install
index 387d88c..f435273 100644
--- a/core/modules/simpletest/simpletest.install
+++ b/core/modules/simpletest/simpletest.install
@@ -8,7 +8,7 @@
 /**
  * Minimum value of PHP memory_limit for SimpleTest.
  */
-const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT = '64M';
+const SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT = '64 MiB';
 
 /**
  * Implements hook_requirements().
@@ -62,8 +62,7 @@ function simpletest_requirements($phase) {
 
   // Check the current memory limit. If it is set too low, SimpleTest will fail
   // to load all tests and throw a fatal error.
-  $memory_limit = ini_get('memory_limit');
-  if (!drupal_check_memory_limit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
+  if (!drupal_check_memory_limit(SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT)) {
     $requirements['php_memory_limit']['severity'] = REQUIREMENT_ERROR;
     $requirements['php_memory_limit']['description'] = $t('The testing framework requires the PHP memory limit to be at least %memory_minimum_limit. The current value is %memory_limit. <a href="@url">Follow these steps to continue</a>.', array('%memory_limit' => $memory_limit, '%memory_minimum_limit' => SIMPLETEST_MINIMUM_PHP_MEMORY_LIMIT, '@url' => 'http://drupal.org/node/207036'));
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/MiscUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/MiscUnitTest.php
index f94c419..3cd9f43 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/MiscUnitTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/MiscUnitTest.php
@@ -26,21 +26,14 @@ public static function getInfo() {
    * Tests that the drupal_check_memory_limit() function works as expected.
    */
   function testCheckMemoryLimit() {
-    $memory_limit = ini_get('memory_limit');
     // Test that a very reasonable amount of memory is available.
-    $this->assertTrue(drupal_check_memory_limit('30MB'), '30MB of memory tested available.');
-
-    // Get the available memory and multiply it by two to make it unreasonably
-    // high.
-    $twice_avail_memory = ($memory_limit * 2) . 'MB';
-    // The function should always return true if the memory limit is set to -1.
-    $this->assertTrue(drupal_check_memory_limit($twice_avail_memory, -1), 'drupal_check_memory_limit() returns TRUE when a limit of -1 (none) is supplied');
+    $this->assertTrue(drupal_check_memory_limit('30 MB'), '30 MB of memory tested available.');
 
     // Test that even though we have 30MB of memory available - the function
     // returns FALSE when given an upper limit for how much memory can be used.
-    $this->assertFalse(drupal_check_memory_limit('30MB', '16MB'), 'drupal_check_memory_limit() returns FALSE with a 16MB upper limit on a 30MB requirement.');
+    $this->assertFalse(drupal_check_memory_limit('30 MB', '16 MB'), 'drupal_check_memory_limit() returns FALSE with a 16MB upper limit on a 30MB requirement.');
 
     // Test that an equal amount of memory to the amount requested returns TRUE.
-    $this->assertTrue(drupal_check_memory_limit('30MB', '30MB'), 'drupal_check_memory_limit() returns TRUE when requesting 30MB on a 30MB requirement.');
+    $this->assertTrue(drupal_check_memory_limit('30 MB', '30 MB'), 'drupal_check_memory_limit() returns TRUE when requesting 30MB on a 30MB requirement.');
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/SizeUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/ByteCountUnitTest.php
similarity index 41%
rename from core/modules/system/lib/Drupal/system/Tests/Common/SizeUnitTest.php
rename to core/modules/system/lib/Drupal/system/Tests/Common/ByteCountUnitTest.php
index a8a2662..d1a6b30 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/SizeUnitTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/ByteCountUnitTest.php
@@ -10,36 +10,55 @@
 use Drupal\simpletest\UnitTestBase;
 
 /**
- * Tests file size parsing and formatting functions.
+ * Tests byte count parsing and formatting functions.
  */
-class SizeUnitTest extends UnitTestBase {
+class ByteCountUnitTest extends UnitTestBase {
   protected $exact_test_cases;
   protected $rounded_test_cases;
 
   public static function getInfo() {
     return array(
-      'name' => 'Size parsing test',
+      'name' => 'Byte count parsing and formatting',
       'description' => 'Parse a predefined amount of bytes and compare the output with the expected value.',
       'group' => 'Common',
     );
   }
 
   function setUp() {
-    $kb = DRUPAL_KILOBYTE;
     $this->exact_test_cases = array(
-      '1 byte' => 1,
-      '1 KB'   => $kb,
-      '1 MB'   => $kb * $kb,
-      '1 GB'   => $kb * $kb * $kb,
-      '1 TB'   => $kb * $kb * $kb * $kb,
-      '1 PB'   => $kb * $kb * $kb * $kb * $kb,
-      '1 EB'   => $kb * $kb * $kb * $kb * $kb * $kb,
-      '1 ZB'   => $kb * $kb * $kb * $kb * $kb * $kb * $kb,
-      '1 YB'   => $kb * $kb * $kb * $kb * $kb * $kb * $kb * $kb,
+      '1 B' => 1,
+      '1 kB' => DRUPAL_KILOBYTE,
+      '1 MB' => pow(DRUPAL_KILOBYTE, 2),
+      '1 GB' => pow(DRUPAL_KILOBYTE, 3),
+      '1 TB' => pow(DRUPAL_KILOBYTE, 4),
+      '1 PB' => pow(DRUPAL_KILOBYTE, 5),
+      '1 EB' => pow(DRUPAL_KILOBYTE, 6),
+      '1 ZB' => pow(DRUPAL_KILOBYTE, 7),
+      '1 YB' => pow(DRUPAL_KILOBYTE, 8),
+    );
+    $this->exact_iec_test_cases = array(
+      '1 KiB' => DRUPAL_KIBIBYTE,
+      '1 MiB' => pow(DRUPAL_KIBIBYTE, 2),
+      '1 GiB' => pow(DRUPAL_KIBIBYTE, 3),
+      '1 TiB' => pow(DRUPAL_KIBIBYTE, 4),
+      '1 PiB' => pow(DRUPAL_KIBIBYTE, 5),
+      '1 EiB' => pow(DRUPAL_KIBIBYTE, 6),
+      '1 ZiB' => pow(DRUPAL_KIBIBYTE, 7),
+      '1 YiB' => pow(DRUPAL_KIBIBYTE, 8),
+    );
+    $this->exact_force_iec_test_cases = array(
+      '1 kB' => DRUPAL_KIBIBYTE,
+      '1 MB' => pow(DRUPAL_KIBIBYTE, 2),
+      '1 GB' => pow(DRUPAL_KIBIBYTE, 3),
+      '1 TB' => pow(DRUPAL_KIBIBYTE, 4),
+      '1 PB' => pow(DRUPAL_KIBIBYTE, 5),
+      '1 EB' => pow(DRUPAL_KIBIBYTE, 6),
+      '1 ZB' => pow(DRUPAL_KIBIBYTE, 7),
+      '1 YB' => pow(DRUPAL_KIBIBYTE, 8),
     );
     $this->rounded_test_cases = array(
-      '2 bytes' => 2,
-      '1 MB' => ($kb * $kb) - 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!)
+      '2 B' => 2,
+      '1 MB' => DRUPAL_KILOBYTE * DRUPAL_KILOBYTE + 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!)
       round(3623651 / ($this->exact_test_cases['1 MB']), 2) . ' MB' => 3623651, // megabytes
       round(67234178751368124 / ($this->exact_test_cases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes
       round(235346823821125814962843827 / ($this->exact_test_cases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes
@@ -48,13 +67,13 @@ function setUp() {
   }
 
   /**
-   * Checks that format_size() returns the expected string.
+   * Check that format_byte_count() returns the expected string.
    */
-  function testCommonFormatSize() {
+  function testCommonFormatByteCount() {
     foreach (array($this->exact_test_cases, $this->rounded_test_cases) as $test_cases) {
       foreach ($test_cases as $expected => $input) {
         $this->assertEqual(
-          ($result = format_size($input, NULL)),
+          ($result = format_byte_count($input, NULL)),
           $expected,
           $expected . ' == ' . $result . ' (' . $input . ' bytes)'
         );
@@ -63,46 +82,62 @@ function testCommonFormatSize() {
   }
 
   /**
-   * Checks that parse_size() returns the proper byte sizes.
+   * Check that parse_byte_count() returns the proper byte sizes.
    */
-  function testCommonParseSize() {
-    foreach ($this->exact_test_cases as $string => $size) {
+  function testCommonParseByteCount() {
+    foreach (array($this->exact_test_cases, $this->exact_iec_test_cases) as $test_cases) {
+      foreach ($test_cases as $string => $size) {
+        $this->assertEqual(
+          $parsed_size = parse_byte_count($string),
+          $size,
+          $size . ' == ' . $parsed_size . ' (' . $string . ')'
+        );
+      }
+    }
+
+    foreach ($this->exact_force_iec_test_cases as $string => $size) {
       $this->assertEqual(
-        $parsed_size = parse_size($string),
+        $parsed_size = parse_byte_count($string, TRUE),
         $size,
         $size . ' == ' . $parsed_size . ' (' . $string . ')'
       );
     }
 
     // Some custom parsing tests
+    $string = '484302293';  // Test parsing byte count with no units.
+    $this->assertEqual(
+      ($parsed_size = parse_byte_count($string)),
+      $size = 484302293,
+      $string . ' == ' . $parsed_size . ' bytes'
+    );
     $string = '23476892 bytes';
     $this->assertEqual(
-      ($parsed_size = parse_size($string)),
+      ($parsed_size = parse_byte_count($string)),
       $size = 23476892,
       $string . ' == ' . $parsed_size . ' bytes'
     );
     $string = '76MRandomStringThatShouldBeIgnoredByParseSize.'; // 76 MB
     $this->assertEqual(
-      $parsed_size = parse_size($string),
-      $size = 79691776,
+      $parsed_size = parse_byte_count($string),
+      $size = 76000000,
       $string . ' == ' . $parsed_size . ' bytes'
     );
-    $string = '76.24 Giggabyte'; // Misspeld text -> 76.24 GB
+    $string = '76.24 Gubibytes'; // Misspeld text -> 76.24 GiB
     $this->assertEqual(
-      $parsed_size = parse_size($string),
-      $size = 81862076662,
+      $parsed_size = parse_byte_count($string),
+      $size = 81862076661,
       $string . ' == ' . $parsed_size . ' bytes'
     );
   }
 
   /**
-   * Cross-tests parse_size() and format_size().
+   * Cross-test parse_byte_count() and format_byte_count().
    */
-  function testCommonParseSizeFormatSize() {
+  function testCommonParseFormatByteCount() {
     foreach ($this->exact_test_cases as $size) {
       $this->assertEqual(
         $size,
-        ($parsed_size = parse_size($string = format_size($size, NULL))),
+        ($parsed_size = parse_byte_count($string = format_byte_count($size))),
         $size . ' == ' . $parsed_size . ' (' . $string . ')'
       );
     }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
index cb68737..9c81bce 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/UserPictureUpgradePathTest.php
@@ -54,7 +54,7 @@ public function testUserPictureUpgrade() {
     $this->assertTrue(isset($usage['image']['default_image'][$field['uuid']]));
 
     $this->assertEqual($instance['settings']['max_resolution'], '800x800', 'User picture maximum resolution has been migrated.');
-    $this->assertEqual($instance['settings']['max_filesize'], '700 KB', 'User picture maximum filesize has been migrated.');
+    $this->assertEqual($instance['settings']['max_filesize'], '700 kB', 'User picture maximum filesize has been migrated.');
     $this->assertEqual($instance['description'], 'These are user picture guidelines.', 'User picture guidelines are now the user picture field description.');
     $this->assertEqual($instance['settings']['file_directory'], 'user_pictures_dir', 'User picture directory path has been migrated.');
 
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index b7b4209..bb54d88 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -196,14 +196,14 @@ function system_requirements($phase) {
     );
   }
 
-  // Test PHP memory_limit
-  $memory_limit = ini_get('memory_limit');
+  // Test PHP memory_limit.
+  $memory_limit = drupal_memory_limit();
   $requirements['php_memory_limit'] = array(
     'title' => $t('PHP memory limit'),
-    'value' => $memory_limit == -1 ? t('-1 (Unlimited)') : $memory_limit,
+    'value' => $memory_limit ? format_byte_count($memory_limit, TRUE) : t('Unlimited'),
   );
 
-  if (!drupal_check_memory_limit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT, $memory_limit)) {
+  if (!drupal_check_memory_limit(DRUPAL_MINIMUM_PHP_MEMORY_LIMIT)) {
     $description = '';
     if ($phase == 'install') {
       $description = $t('Consider increasing your PHP memory limit to %memory_minimum_limit to help prevent errors in the installation process.', array('%memory_minimum_limit' => DRUPAL_MINIMUM_PHP_MEMORY_LIMIT));
diff --git a/core/modules/system/system.tokens.inc b/core/modules/system/system.tokens.inc
index 241ed54..13a84fa 100644
--- a/core/modules/system/system.tokens.inc
+++ b/core/modules/system/system.tokens.inc
@@ -238,7 +238,7 @@ function system_tokens($type, $tokens, array $data = array(), array $options = a
           break;
 
         case 'size':
-          $replacements[$original] = format_size($file->filesize);
+          $replacements[$original] = format_byte_count($file->filesize);
           break;
 
         case 'url':
diff --git a/core/modules/user/user.install b/core/modules/user/user.install
index 4f22958..e089b0e 100644
--- a/core/modules/user/user.install
+++ b/core/modules/user/user.install
@@ -328,7 +328,7 @@ function user_install_picture_field() {
     'settings' => array(
       'file_extensions' => 'png gif jpg jpeg',
       'file_directory' => 'pictures',
-      'max_filesize' => '30 KB',
+      'max_filesize' => '30 kB',
       'alt_field' => 0,
       'title_field' => 0,
       'max_resolution' => '85x85',
@@ -727,7 +727,7 @@ function user_update_8011() {
     'settings' => array(
       'file_extensions' => 'png gif jpg jpeg',
       'file_directory' => update_variable_get('user_picture_path', 'pictures'),
-      'max_filesize' => update_variable_get('user_picture_file_size', '30') . ' KB',
+      'max_filesize' => update_variable_get('user_picture_file_size', '30') . ' kB',
       'alt_field' => 0,
       'title_field' => 0,
       'max_resolution' => update_variable_get('user_picture_dimensions', '85x85'),
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/FileSize.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/FileSize.php
index 1bfa5ea..71a176f 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/field/FileSize.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/FileSize.php
@@ -32,7 +32,7 @@ public function buildOptionsForm(&$form, &$form_state) {
       '#title' => t('File size display'),
       '#type' => 'select',
       '#options' => array(
-        'formatted' => t('Formatted (in KB or MB)'),
+        'formatted' => t('Formatted (in kB or MB)'),
         'bytes' => t('Raw bytes'),
       ),
     );
@@ -46,7 +46,7 @@ function render($values) {
           return $value;
         case 'formatted':
         default:
-          return format_size($value);
+          return format_byte_count($value);
       }
     }
     else {
diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php
index f7fa8bc..adbd63c 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Handler/FieldFileSizeTest.php
@@ -64,9 +64,9 @@ public function testFieldFileSize() {
 
     // Test with the formatted option.
     $this->assertEqual($view->field['age']->advanced_render($view->result[0]), '');
-    $this->assertEqual($view->field['age']->advanced_render($view->result[1]), '10 bytes');
-    $this->assertEqual($view->field['age']->advanced_render($view->result[2]), '1000 bytes');
-    $this->assertEqual($view->field['age']->advanced_render($view->result[3]), '9.77 KB');
+    $this->assertEqual($view->field['age']->advanced_render($view->result[1]), '10 B');
+    $this->assertEqual($view->field['age']->advanced_render($view->result[2]), '1 kB');
+    $this->assertEqual($view->field['age']->advanced_render($view->result[3]), '10 kB');
     // Test with the bytes option.
     $view->field['age']->options['file_size_display'] = 'bytes';
     $this->assertEqual($view->field['age']->advanced_render($view->result[0]), '');
diff --git a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
index d4ba19a..743c0d3 100644
--- a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
+++ b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
@@ -39,7 +39,7 @@ function testSizedMessages() {
       $xml_message_l = xmlrpc_test_message_sized_in_kb($size);
       $xml_message_r = xmlrpc($xml_url, array('messages.messageSizedInKB' => array($size)));
 
-      $this->assertEqual($xml_message_l, $xml_message_r, format_string('XML-RPC messages.messageSizedInKB of %s Kb size received', array('%s' => $size)));
+      $this->assertEqual($xml_message_l, $xml_message_r, format_string('XML-RPC messages.messageSizedInKB of %s kB size received', array('%s' => $size)));
     }
   }
 
diff --git a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
index 11c86c3..ed9a1ee 100644
--- a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
+++ b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
@@ -87,10 +87,10 @@ function xmlrpc_test_xmlrpc_alter(&$services) {
 }
 
 /**
- * Created a message of the desired size in KB.
+ * Created a message of the desired size in kB.
  *
  * @param $size
- *   Message size in KB.
+ *   Message size in kB.
  * @return array
  *   Generated message structure.
  */
@@ -99,7 +99,7 @@ function xmlrpc_test_message_sized_in_kb($size) {
 
   $word = 'abcdefg';
 
-  // Create a ~1KB sized struct.
+  // Create a ~1 kB sized struct.
   for ($i = 0 ; $i < 128; $i++) {
     $line['word_' . $i] = $word;
   }
