what are the following C datatypes Equivalents in Matlab

6 ビュー (過去 30 日間)
Imtiaz nabi
Imtiaz nabi 2022 年 4 月 12 日
回答済み: Rik 2022 年 4 月 12 日
Hello, I wanted to understand the equavalent data types of C in matab.
for example if we have a "long" in C do we need to use int16 in matlab to represent the long integer?
I am sorry if this seems like a super noob question but I am like super confused about these things.
Also can you please let me know the equavalents of the following data types in matlab?
  • long
  • unsigned long
  • int
  • signed long
  2 件のコメント
Henry Barth
Henry Barth 2022 年 4 月 12 日
Although there are "exact" representations of most c types in matlab (using cast() and typecast()), I would recommend you use double for everything as matlab allows 99% of builtin mathematical functions to use this type. You can use realmax() and intmax() fucntions to check if your type's maximum is included in double
Imtiaz nabi
Imtiaz nabi 2022 年 4 月 12 日
Thank you so much

サインインしてコメントする。

採用された回答

Rik
Rik 2022 年 4 月 12 日
Integer names in Matlab are much more clear than in C: uint8 uint16 uint32 uint64 int8 int16 int32 int64. The ones starting with u are unsigned, the others are signed.
The advice Henry gave you is valid: most functions will assume you're working with double (which is conveniently the same as a C double) and will be optimized for that use case.
Prior to R2010b, the support for actual operations with the integer data types was very limited (i.e. even plus didn't work). Since then, most functions will work with them, although some will convert to double internally.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by