Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Double Precision

Subject: Double Precision

From: Hosein

Date: 25 Feb, 2009 13:21:01

Message: 1 of 13

I used "Double Precision" on top of my main code. Does it mean that it works for all operations even in subroutines and functions?

Subject: Double Precision

From: Walter Roberson

Date: 25 Feb, 2009 15:38:58

Message: 2 of 13

Hosein wrote:
> I used "Double Precision" on top of my main code. Does it mean that it works for all
> operations even in subroutines and functions?

Are you sure that is in a matlab program??

I figure that in matlab,

Double Precision

would be equivalent to

Double('Precision')

As Matlab still permits some fuzzy matching about upper vs lower case, I think this
would be interpreted as

double('Precision')

which would take the character string array ['P' 'r' 'e'] and so on and convert
the data type from char to double precision floating point. The code would be
equivalent to

'Precision' + 0.

and the output would be a series of 9 numbers.

Subject: Double Precision

From: Hosein

Date: 25 Feb, 2009 15:52:01

Message: 3 of 13

Walter Roberson <roberson@hushmail.com> wrote in message <PCdpl.23889$_U5.15720@newsfe20.iad>...
> Hosein wrote:
> > I used "Double Precision" on top of my main code. Does it mean that it works for all
> > operations even in subroutines and functions?
>
> Are you sure that is in a matlab program??
>
> I figure that in matlab,
>
> Double Precision
>
> would be equivalent to
>
> Double('Precision')
>
> As Matlab still permits some fuzzy matching about upper vs lower case, I think this
> would be interpreted as
>
> double('Precision')
>
> which would take the character string array ['P' 'r' 'e'] and so on and convert
> the data type from char to double precision floating point. The code would be
> equivalent to
>
> 'Precision' + 0.
>
> and the output would be a series of 9 numbers.

I am working with very small numbers and it is important to include all digits in all operations. Since Matlab did not give me any error messages, I though it was OK to use "Double Precision".
According to my problem, Which one would be better: "Double Precision" or double('precision')?

Subject: Double Precision

From: tpl@eng.cam.ac.uk (Tim Love)

Date: 25 Feb, 2009 16:13:34

Message: 4 of 13

"Hosein" <Kalaeimh@yahoo.com> writes:

>I am working with very small numbers and it is important to include all digits in all operations.
By default, matlab uses double precision. Maybe you just need to look up the
format command?

Subject: Double Precision

From: Walter Roberson

Date: 25 Feb, 2009 16:44:34

Message: 5 of 13

Tim Love wrote:
> "Hosein" <Kalaeimh@yahoo.com> writes:
>
>> I am working with very small numbers and it is important to include all digits in all operations.
> By default, matlab uses double precision. Maybe you just need to look up the
> format command?

Correct for sufficiently new versions of Matlab; if I recall correctly, Roger's version
still defaults to single precision. Maybe there's a "Double Precision" command that is
so obsolete that I've simply never heard of it ?

Subject: Double Precision

From: Steven Lord

Date: 25 Feb, 2009 19:27:37

Message: 6 of 13


"Walter Roberson" <roberson@hushmail.com> wrote in message
news:iAepl.29276$pX4.17109@newsfe08.iad...
> Tim Love wrote:
>> "Hosein" <Kalaeimh@yahoo.com> writes:
>>
>>> I am working with very small numbers and it is important to include all
>>> digits in all operations.
>> By default, matlab uses double precision. Maybe you just need to look up
>> the
>> format command?
>
> Correct for sufficiently new versions of Matlab; if I recall correctly,
> Roger's version
> still defaults to single precision. Maybe there's a "Double Precision"
> command that is
> so obsolete that I've simply never heard of it ?

As far as I am aware, MATLAB has always used double precision as default [or
if there was a time when it didn't, it was a Long Time Ago.] I don't think
sufficiently old versions of MATLAB have single precision as a data type.
If I remember correctly, single precision was included in MATLAB starting
with version 5.0.

I think we'll need to see some code from the OP (Original Poster) before we
can determine what they mean by "Double Precision".

--
Steve Lord
slord@mathworks.com

Subject: Double Precision

From: Roger Stafford

Date: 25 Feb, 2009 20:26:02

Message: 7 of 13

"Steven Lord" <slord@mathworks.com> wrote in message <go4639$kgc$1@fred.mathworks.com>...
> "Walter Roberson" <roberson@hushmail.com> wrote in message
> news:iAepl.29276$pX4.17109@newsfe08.iad...
> > Correct for sufficiently new versions of Matlab; if I recall correctly,
> > Roger's version
> > still defaults to single precision. .....
> As far as I am aware, MATLAB has always used double precision as default [or
> if there was a time when it didn't, it was a Long Time Ago.] I don't think
> sufficiently old versions of MATLAB have single precision as a data type.
> If I remember correctly, single precision was included in MATLAB starting
> with version 5.0.
> .......
> Steve Lord

  Yes, that is correct Steve. My ancient version 4a does not have single precision, only double precision.

Roger Stafford

Subject: Double Precision

From: Hosein

Date: 26 Feb, 2009 16:28:02

Message: 8 of 13

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <go49gq$lo1$1@fred.mathworks.com>...
> "Steven Lord" <slord@mathworks.com> wrote in message <go4639$kgc$1@fred.mathworks.com>...
> > "Walter Roberson" <roberson@hushmail.com> wrote in message
> > news:iAepl.29276$pX4.17109@newsfe08.iad...
> > > Correct for sufficiently new versions of Matlab; if I recall correctly,
> > > Roger's version
> > > still defaults to single precision. .....
> > As far as I am aware, MATLAB has always used double precision as default [or
> > if there was a time when it didn't, it was a Long Time Ago.] I don't think
> > sufficiently old versions of MATLAB have single precision as a data type.
> > If I remember correctly, single precision was included in MATLAB starting
> > with version 5.0.
> > .......
> > Steve Lord
>
> Yes, that is correct Steve. My ancient version 4a does not have single precision, only double precision.
>
> Roger Stafford

How many digits are involved when it is double precision?
Can we involve more digits on the calculation? like FORTRAN: Quadrant precision
Hosein

Subject: Double Precision

From: Walter Roberson

Date: 26 Feb, 2009 19:49:11

Message: 9 of 13

Hosein wrote:
 
> How many digits are involved when it is double precision?

IEEE standard 1 bit sign, 11 bit exponent, one hidden '1' bit (if not denormalized),
and 52 mantissa bits.

> Can we involve more digits on the calculation? like FORTRAN: Quadrant precision

There is no provision for 128 bit floating point calculations in any version of
Matlab that I am aware of. If you need more then 12/52 then use the symbolic
toolbox and set Digits as high as you need.

Subject: Double Precision

From: John D'Errico

Date: 26 Feb, 2009 20:46:02

Message: 10 of 13

Walter Roberson <roberson@hushmail.com> wrote in message <iAepl.29276$pX4.17109@newsfe08.iad>...
> Tim Love wrote:
> > "Hosein" <Kalaeimh@yahoo.com> writes:
> >
> >> I am working with very small numbers and it is important to include all digits in all operations.
> > By default, matlab uses double precision. Maybe you just need to look up the
> > format command?
>
> Correct for sufficiently new versions of Matlab; if I recall correctly, Roger's version
> still defaults to single precision. Maybe there's a "Double Precision" command that is
> so obsolete that I've simply never heard of it ?

No, Roger's version does not default to single.
In fact, it was only a somewhat recent advance
that single was even an option asa data type.

John

Subject: Double Precision

From: Ali sharadqah

Date: 29 Mar, 2009 22:14:01

Message: 11 of 13

I know that matlab use double precision but I would like to use the single Precision in all command of my code so my code will run faster. could someone help me in this issue
Ali
"John D'Errico" <woodchips@rochester.rr.com> wrote in message <go6v29$4ub$1@fred.mathworks.com>...
> Walter Roberson <roberson@hushmail.com> wrote in message <iAepl.29276$pX4.17109@newsfe08.iad>...
> > Tim Love wrote:
> > > "Hosein" <Kalaeimh@yahoo.com> writes:
> > >
> > >> I am working with very small numbers and it is important to include all digits in all operations.
> > > By default, matlab uses double precision. Maybe you just need to look up the
> > > format command?
> >
> > Correct for sufficiently new versions of Matlab; if I recall correctly, Roger's version
> > still defaults to single precision. Maybe there's a "Double Precision" command that is
> > so obsolete that I've simply never heard of it ?
>
> No, Roger's version does not default to single.
> In fact, it was only a somewhat recent advance
> that single was even an option asa data type.
>
> John

Subject: Double Precision

From: John D'Errico

Date: 30 Mar, 2009 00:26:01

Message: 12 of 13

"Ali sharadqah" <alsha1aa@uab.edu> wrote in message <gqorr9$2f6$1@fred.mathworks.com>...
> I know that matlab use double precision but I would like to use the single Precision in all command of my code so my code will run faster. could someone help me in this issue

help single

You won't get that much more speed though.

John

Subject: Double Precision

From: Chaos

Date: 30 Mar, 2009 00:49:01

Message: 13 of 13

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <gqp3ip$lff$1@fred.mathworks.com>...
> "Ali sharadqah" <alsha1aa@uab.edu> wrote in message <gqorr9$2f6$1@fred.mathworks.com>...
> > I know that matlab use double precision but I would like to use the single Precision in all command of my code so my code will run faster. could someone help me in this issue
>
> help single
>
> You won't get that much more speed though.
>
> John

he might, if he throws his code at the GPU. there's a matlab toolbox for GPU processing that is only SP. look around for lightspeed.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us