Double-precision arrays - MATLAB (2024)

Double-precision arrays

expand all in page

Description

double is the default numeric data type (class) in MATLAB®, providing sufficient precision for most computational tasks. Numeric variables are automatically stored as 64-bit (8-byte) double-precision floating-point values. For example:

x = 10;whos x
 Name Size Bytes Class Attributes x 1x1 8 double 

MATLAB constructs the double data type according to IEEE® Standard 754 for double precision. The range for a negative number of type double is between -1.79769 x 10308 and -2.22507 x 10-308, and the range for positive numbers is between 2.22507 x 10-308 and 1.79769 x 10308.

For more information on double- and single-precision floating-point values, see Floating-Point Numbers.

Creation

You create a double-precision array automatically when you assign a numeric scalar or array to a variable, such as A = [1 2 3; 4 5 6]. The variable A has type double. For more information on creating and combining arrays, see Creating, Concatenating, and Expanding Matrices. In addition, operations on double-precision variables and functions with double-precision input typically return double-precision values, such as + or sin.

If you have an array of a different data type, such as single or int8, then you can convert that array to double precision using the double function, which then stores the array with more precision for further computations.

Syntax

Y = double(X)

Description

example

Y = double(X) converts the values in X to double precision.

Input Arguments

expand all

Input array, specified as a scalar, vector, matrix, or multidimensional array.

Data Types: single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | string

Examples

collapse all

Create Double-Precision Variable

Open Live Script

By default, numbers in MATLAB are of the data type double. You can use the class function to verify a variable's type.

x = 100;xtype = class(x)
xtype = 'double'

Use the double function to convert variables that are not double precision to type double.

y = true
y = logical 1
ydouble = double(y);ynewtype = class(ydouble)
ynewtype = 'double'

Double-Precision Versus Single-Precision

Open Live Script

Compare the ranges of numeric values in double-precision to the ranges for single-precision.

Use the realmin and realmax functions to display the minimum and maximum positives values that can be represented in double precision.

doublemin = realmin('double')
doublemin = 2.2251e-308
doublemax = realmax('double')
doublemax = 1.7977e+308

Now display the minimum and maximum positive values that can be represented in single precision. The range of values is smaller compared to double-precision, but requires less memory.

singlemin = realmin('single')
singlemin = single 1.1755e-38
singlemax = realmax('single')
singlemax = single 3.4028e+38

The eps function returns a measure of how close numbers can be in double-precision versus single-precision. Display the distance from the number 1.0 to the next larger double-precision number.

doubleeps = eps('double')
doubleeps = 2.2204e-16

Now display the distance from 1.0 to the next larger single-precision number. Double-precision values are closer to each other, since you can represent more of them.

singleeps = eps('single')
singleeps = single 1.1921e-07

Tips

  • When you are creating a class, overload double when it makes sense to convert an object of that class to a double-precision value.

  • Converting a char array to a numeric type will produce an array of the corresponding Unicode® code values. Text in strings does not convert in this way. Converting a string that does not represent a single numeric value to double will produce a NaN result. For more information, see Unicode and ASCII Values.

Extended Capabilities

This function fully supports tall arrays. Formore information, see Tall Arrays.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).

Version History

Introduced before R2006a

See Also

cast | single | str2double | typecast | realmin | realmax | eps

Topics

  • Floating-Point Numbers
  • Identifying Numeric Classes
Double-precision arrays - MATLAB (2024)

References

Top Articles
1. Overview of Google Workspace for Education storage
Dr. Joseph Ladapo: What we know about Florida's Surgeon General
English Bulldog Puppies For Sale Under 1000 In Florida
Collision Masters Fairbanks
Caroline Cps.powerschool.com
Bloxburg Image Ids
Minn Kota Paws
Comenity Credit Card Guide 2024: Things To Know And Alternatives
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Full Range 10 Bar Selection Box
Craigslist Deming
Current Time In Maryland
No Hard Feelings Showtimes Near Cinemark At Harlingen
How Much Are Tb Tests At Cvs
Best Forensic Pathology Careers + Salary Outlook | HealthGrad
Craigslist Toy Hauler For Sale By Owner
U Break It Near Me
How to Watch the Fifty Shades Trilogy and Rom-Coms
Closest Bj Near Me
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Cbssports Rankings
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Melendez Imports Menu
Criterion Dryer Review
Cosas Aesthetic Para Decorar Tu Cuarto Para Imprimir
Viduthalai Movie Download
Does Royal Honey Work For Erectile Dysfunction - SCOBES-AR
Earthy Fuel Crossword
Shauna's Art Studio Laurel Mississippi
Ancestors The Humankind Odyssey Wikia
Inmate Search Disclaimer – Sheriff
Rock Salt Font Free by Sideshow » Font Squirrel
Craigslist Free Puppy
Cbs Trade Value Chart Week 10
Gasbuddy Lenoir Nc
Lichen - 1.17.0 - Gemsbok! Antler Windchimes! Shoji Screens!
Kips Sunshine Kwik Lube
Top-ranked Wisconsin beats Marquette in front of record volleyball crowd at Fiserv Forum. What we learned.
Powerspec G512
Plead Irksomely Crossword
1v1.LOL Game [Unblocked] | Play Online
O'reilly's Palmyra Missouri
manhattan cars & trucks - by owner - craigslist
Best Restaurants West Bend
Traumasoft Butler
Fool's Paradise Showtimes Near Roxy Stadium 14
Alpha Labs Male Enhancement – Complete Reviews And Guide
Enr 2100
Anonib New
Enjoy Piggie Pie Crossword Clue
Freightliner Cascadia Clutch Replacement Cost
Wwba Baseball
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 5597

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.