This is the third article in the LabVIEW NXG series in which we look at simple data types and simple conversions between them.
![](https://habrastorage.org/webt/dy/nb/fs/dynbfs1fxqsix-mq0xplhsaq-jc.png)
The LabVIEW type system is very similar to the "classic" programming languages. In this article we will consider the basic types - numerical, Boolean, and strings (although formally strings do not belong to simple scalar types).
The easiest way to understand the type system is to make a small tool with controls and indicators of different types:
![](https://habrastorage.org/webt/ea/oz/_u/eaoz_ufoijkikiu-tegf6ds2e6s.png)
and connect them on the diagram like this:
![](https://habrastorage.org/webt/gn/kq/ni/gnkqnijtzit1xedyhpc2yx79iac.png)
, " In" " Out". LabVIEW, , ( ).
โ , 8, 16, 32 64 , ( 4 8 ), โ . :
![](https://habrastorage.org/webt/id/su/kr/idsukrkvyiqj_rz6gltpis8jsws.png)
:
![](https://habrastorage.org/webt/iv/om/xw/ivomxwc9aqezh2ecyxcvxf2a1ea.png)
( , ). , ? :
![](https://habrastorage.org/webt/qp/v-/yh/qpv-yhtdbyabvehms8bxug2e6au.png)
"" ( Coercion Dots), , .
SGL DBL , , U8 I32, , DBL->SGL, DBL->I32 I32->U8 , :
![](https://habrastorage.org/webt/ni/ho/kl/nihoklkcm1ufw0jynufhujuhjro.png)
"" LabVIEW Coercion Dots , :
![](https://habrastorage.org/webt/ho/bz/lp/hobzlpfctludklwxtjd07q0ybni.png)
, ? , Data Types->Numeric->Conversion:
![](https://habrastorage.org/webt/3b/hx/6h/3bhx6hegzazrlnfspydqwhzvnzg.png)
:
![](https://habrastorage.org/webt/d9/no/ia/d9noiav1iifrssa9kcr0bkz1b-i.png)
Coercion Dot, .
![](https://habrastorage.org/webt/1k/i1/r7/1ki1r74juadbcs64udkmlbpjt7i.png)
, , , DBL, :
![](https://habrastorage.org/webt/ev/n2/ph/evn2ph1m0uboyznddkgwulaxibm.png)
, , ( LabVIEW Compound Arithmetic):
![](https://habrastorage.org/webt/a5/nw/bz/a5nwbzq91s3igfojzm-y70_z_ay.png)
LabVIEW . , :
double res;
res = 5/3;
Console.WriteLine(res);
"1".
LabVIEW , 1,66 (1,66666666666667 ):
![](https://habrastorage.org/webt/wr/6p/c-/wr6pc-1zsxtnanz_iedn01z-tv8.png)
, LabVIEW , , , C# ( "" ).
, , :
![](https://habrastorage.org/webt/xw/1g/fv/xw1gfvviu8ex2bv2a2tm5erxpbk.png)
, . , , , :
![](https://habrastorage.org/webt/7o/il/yu/7oilyurbffdtqx-fj_0_vdpjhxc.png)
C# ( , int, , :
static void Main(string[] args)
{
byte x_U8 = 200, y_U8 = 200, res_U8;
res_U8 = x_U8 + y_U8;
Console.WriteLine(res_U8);
}
:
res_U8 = (byte)(x_U8 + y_U8);
, LabVIEW, , LabVIEW , , ( ):
![](https://habrastorage.org/webt/zo/gs/vr/zogsvryi6frz08tk4es4cfuiql4.png)
, , :
![](https://habrastorage.org/webt/qo/8d/4h/qo8d4h4afa288qchuezzhex-ewa.png)
LabVIEW ( "" ) โ .
LabVIEW C# Microsoft, :
class Program
{
static void Main(string[] args)
{
Console.WriteLine(5.0/0.0);
}
}
"8". , , "", "Infinity", . , .NET Core โ , ( , , " " Windows 10 2004). , , , , , , , .
, , LabVIEW:
![](https://habrastorage.org/webt/up/si/gq/upsigq71mdcgjs6ztyih6fj-lsk.png)
โ . :
![](https://habrastorage.org/webt/p6/5a/im/p65aima-iy90rm8f5a-yoawgazm.png)
, NaN (Not a Number):
![](https://habrastorage.org/webt/tm/je/gk/tmjegk8pliyzqsvpfbft75avo6m.png)
NaN Not a Number? :
![](https://habrastorage.org/webt/x6/iz/qp/x6izqp_lk6zdnpbdezfpq35w274.png)
โ .
.
# :
static void Main(string[] args)
{
Console.WriteLine(5/0);
}
...
static void Main(string[] args)
{
int zero = 0;
Console.WriteLine(5/zero);
}
โฆ System.DivideByZeroException, LabVIEW โ , .
![](https://habrastorage.org/webt/wz/wn/ie/wzwnie9l2dy0ltj0-mudajec8jg.png)
() :
![](https://habrastorage.org/webt/xu/in/ob/xuinobtpd2n5zd7akkm7lvjumu8.png)
Conversions :
![](https://habrastorage.org/webt/q0/fx/ho/q0fxholvjlukfxyozra9w_k38by.png)
:
![](https://habrastorage.org/webt/ox/b0/cf/oxb0cfwu5daa9joxz3lwnyrgkes.png)
, , :
![](https://habrastorage.org/webt/di/cy/to/dicytorhysnuqomqkcs_5rqhuia.png)
:
![](https://habrastorage.org/webt/88/pg/4b/88pg4bw2dkeuxghuk98khw2icro.png)
, , :
static void Main(string[] args)
{
string hello = "Hello, ";
string habr = "Habr!";
Console.WriteLine(hello + habr);
}
LabVIEW " " , :
![](https://habrastorage.org/webt/cw/gz/ay/cwgzaytfecjrfq7tmmsojufscsk.png)
. , Boolean to Integer :
![](https://habrastorage.org/webt/vk/zi/v7/vkziv7f8gcrzvfgjyjjomri03yc.png)
LabVIEW. False:
![](https://habrastorage.org/webt/ep/60/tn/ep60tnfa7wm8yemblh4vzrabs_o.png)
, :
![](https://habrastorage.org/webt/ud/p0/j1/udp0j1qxb_gh4-x4exmtriivvbg.png)
Type Cast
"Type Cast", . :
![](https://habrastorage.org/webt/ou/fw/uo/oufwuosg2zylhn-yjk9udklkzdw.png)
"Type", . "by flattening it and unflattening". "/".
, SGL I32:
![](https://habrastorage.org/webt/yx/oa/co/yxoacon7vvmkfryzogiv04w6260.png)
output? "1040187392". ?
:
![](https://habrastorage.org/webt/pt/91/si/pt91sius0cpjkg66vfbt_bhtixo.png)
This is 0x3E000000. Here the following happens - four bytes of a floating-point number are reinterpreted as a four-byte integer. I intentionally took the number 0.125, because if you look at the representation of 0.125 according to IEEE754, you will see that there are only five bits of the mantissa set - this gives us the value 3E in the high byte.
After three articles, we should work fairly confidently with three types of data:
![](https://habrastorage.org/webt/al/cb/2o/alcb2ocslxgwnyzefx6zb_wctom.png)
If you have any questions about the material presented, ask in the comments, and in the next article we will consider arrays.