Casting to Single in MATLAB

What causes a call typecastin MATLAB?

y=typecast(x,'single');

what does it mean? When I run typecast(3,'single'), it gives 0 2.1250.

I don’t understand what it is.

I am trying to convert this to Java, how can I do this?

In the MATLAB manual:

single - Convert to single precision

Syntax

B = single(A)

Description

B = single(A)converts matrix A to uniform precision, returning this value to B. A can be any numerical object (for example, double). If A is already single precision, the single has no effect. Unit values ​​require less storage than double precision amounts, but have less accuracy and a smaller range.

+3
source share
2 answers

typecast , , . , 3 MATLAB IEEE, 8 .

40 08 00 00 00 00 00 00

single MATLAB - IEEE, 4 . , 4- ,

40 08 00 00, and
00 00 00 00

, 40 08 00 00 2.125, , , 00 00 00 00 0 . , - , , 2.125 0.

++ - reinterpret_cast. Java , , .

+4

help typecast , , , single( ) , .

, , , 8 . , 1 , 2 3 . typecast , 4 .

. , 1 2, . 3 3 .

, [8,3] [4,4,3].

, , single( ) (, int8 single), , .

+1

All Articles