I want to calcute this equation x= 3.0*(4.0/3.0-1.0)-1.0 but using single precision instead of double. How do I do switch to single?

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 27일

0 개 추천

single(x)

댓글 수: 3

Beaya
Beaya 2013년 10월 27일
편집: Beaya 2013년 10월 27일
I'm confused because this equation in supposed to return the value of machine epsilon, however it only works for double precision. I don't know if I am doing something wrong, this is what I type:
x = 1 - 3*(4/3 - 1)
single(x)
and I still get this result: 2.2204e-16 instead of 1.1921e-07
x = 1 - 3*(4/3 - 1)
a=single(x)
whos x a
and see the difference
To get the smallest double and single number
realmin('double')
realmin('single')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2013년 10월 27일

댓글:

2013년 10월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by