PHP is_double() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Variables

Definition

In PHP, is_double() is an alias of is_float(). It checks whether a variable is a floating-point number and returns true or false.

Both functions are identical, so you can use either one. The name is_double comes from C, where a floating-point number is called a double. The preferred name in modern PHP code is is_float(), because it matches the float type name.

Syntax

Call is_double() with the values you need. Start with this line.

PHP
$result = is_double($value);
CallWhat it does
is_double(3.14)Returns true, because 3.14 is a float.
is_double(3)Returns false, because 3 is an integer.
is_double("3.14")Returns false, because a number in quotes is a string.

is_double() is an alias, so it behaves exactly like is_float(). The preferred form is is_float(). Both names work in PHP 8, and neither is deprecated.

Library declarations
PHP
// is_double() is an alias of is_float()
is_double(mixed $value): bool

Parameters

ParameterDescription
valueRequired. The variable or value to test.

Return Value

Return ValueDescription
booltrue if the value is a float, otherwise false.

PHP Examples

Example 1 — Floats and Non-Floats

Test a decimal number, an integer, a numeric string and a number written in scientific notation.

PHP
<?php
var_dump(is_double(3.14));
var_dump(is_double(3));
var_dump(is_double("3.14"));
var_dump(is_double(1e3));

How It Works

  1. 3. 14 has a decimal point, so it is a float.
  2. 3 is a whole number, so it is an integer and the result is false.
  3. A number in quotes is a string, so the result is false.
  4. 1e3 is scientific notation. PHP always treats it as a float, even though its value is 1000.

Example 2 — Results of Arithmetic

The type of a calculation depends on the numbers and the operator.

PHP
<?php
var_dump(is_double(10 / 4));
var_dump(is_double(10 / 2));
var_dump(is_double(2 ** 0.5));
var_dump(is_double(2 ** 3));

How It Works

  1. 10 / 4 does not divide evenly, so PHP returns the float 2. 5.
  2. 10 / 2 divides evenly, so PHP returns the integer 5.
  3. Raising a number to a decimal power gives a float.
  4. Raising an integer to an integer power gives an integer, so 2 ** 3 is the integer 8.

Example 3 — Alias Proof and Special Floats

Confirm that is_double() equals is_float(), and see that NAN and INF count as floats.

PHP
<?php
var_dump(is_double(1.5) === is_float(1.5));
var_dump(is_double(NAN));
var_dump(is_double(INF));
var_dump(is_double("1.5"));

How It Works

  1. Both functions return the same answer for 1. 5, so the strict comparison is true. This proves is_double() is an alias.
  2. NAN means not a number, but its type is still float.
  3. INF means infinity, and its type is also float.
  4. The quoted "1. 5" is a string, so the result is false. In new code, write is_float() instead of is_double().

Frequently Asked Questions

is_double() is an alias of is_float(). It returns true if the variable is a floating-point number and false for any other type.
There is no difference. They are the same function under two names. is_float() is the preferred name in modern PHP.
No. It still works in PHP 8. Only the older alias is_real() was removed in PHP 8.0. Still, is_float() is the clearer choice.
Yes. 5.0 is written with a decimal point, so it is a float. The integer 5 returns false.
is_double() returns false for strings. Use is_numeric() to check whether a string is a valid number, or filter_var($text, FILTER_VALIDATE_FLOAT) to validate it and convert it.

Next: is_float()

is_float() checks whether a variable is a floating-point number, which is a number with a .

is_float() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful