Index: src/wp-includes/meta.php
===================================================================
--- src/wp-includes/meta.php	(revision 27689)
+++ src/wp-includes/meta.php	(working copy)
@@ -833,16 +833,27 @@
 				$meta_value = trim( $meta_value );
 			}
 
+			switch ( $meta_type ) {
+				case 'SIGNED':
+					$cast_string = '%d';
+					break;
+				case 'UNSIGNED':
+					$cast_string = '%u';
+					break;
+				default:
+					$cast_string = '%s';
+					break;
+			}
+			
+			$meta_compare_string = $cast_string;
+
 			if ( 'IN' == substr( $meta_compare, -2) ) {
-				$meta_compare_string = '(' . substr( str_repeat( ',%s', count( $meta_value ) ), 1 ) . ')';
+				$meta_compare_string = '(' . substr( str_repeat( ", $cast_string", count( $meta_value ) ), 1 ) . ')';
 			} elseif ( 'BETWEEN' == substr( $meta_compare, -7) ) {
 				$meta_value = array_slice( $meta_value, 0, 2 );
-				$meta_compare_string = '%s AND %s';
+				$meta_compare_string = "$cast_string AND $cast_string";
 			} elseif ( 'LIKE' == substr( $meta_compare, -4 ) ) {
 				$meta_value = '%' . like_escape( $meta_value ) . '%';
-				$meta_compare_string = '%s';
-			} else {
-				$meta_compare_string = '%s';
 			}
 
 			if ( ! empty( $where[$k] ) )
Index: tests/phpunit/tests/meta/query.php
===================================================================
--- tests/phpunit/tests/meta/query.php	(revision 27689)
+++ tests/phpunit/tests/meta/query.php	(working copy)
@@ -117,7 +117,7 @@
 		) );
 		$sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
 
-		$this->assertEquals( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) = '')" ) );
+		$this->assertEquals( 1, substr_count( $sql['where'], "CAST($wpdb->postmeta.meta_value AS CHAR) = ''" ) );
 	}
 
 	/**
@@ -194,4 +194,21 @@
 		$this->assertContains( "{$wpdb->postmeta}.meta_key = 'exclude'\nOR", $sql['where'] );
 		$this->assertNotContains( "{$wpdb->postmeta}.post_id IS NULL", $sql['where'] );
 	}
+
+	function test_cast_both_sides() {
+		global $wpdb;
+
+		$query = new WP_Meta_Query( array(
+			array(
+				'key'       => 'number_string',
+				'value'     => '1000000',
+				'compare'   => '<=',
+				'type'      => 'NUMERIC',
+			),
+		) );
+
+		$sql = $query->get_sql( 'post', $wpdb->posts, 'ID', $this );
+		$this->assertNotContains( "CAST({$wpdb->postmeta}.meta_value AS SIGNED) <= '1000000'", $sql['where'] );
+		$this->assertContains( "CAST({$wpdb->postmeta}.meta_value AS SIGNED) <= 1000000", $sql['where'] );
+	}
 }
Index: tests/phpunit/tests/meta.php
===================================================================
--- tests/phpunit/tests/meta.php	(revision 27688)
+++ tests/phpunit/tests/meta.php	(working copy)
@@ -180,6 +180,8 @@
 		) );
 
 		$this->assertEquals( array( $post_id2, $post_id1 ), $posts->posts );
+		$this->assertNotContains( "> '0'", $posts->request );
+		$this->assertContains( "> 0", $posts->request );
 		$this->assertEquals( 2, substr_count( $posts->request, 'CAST(' ) );
 	}
 
