首页 > 文档 > byte字节
2017
07-15

byte字节

Name Byte字节
Examples // Declare variable ‘a’ of type byte

byte a;

// Assign 23 to ‘a’

a = 23;

// Declare variable ‘b’ and assign it the value -128

byte b = -128;

// Declare variable ‘c’ and assign it the sum of ‘a’ and ‘b’.

// By default, when two bytes are added, they are converted

// to an integer. To keep the answer as a byte, cast them

// to a byte with the byte() conversion function

byte c = byte(a + b);

Description

描述

Datatype for bytes, 8 bits of information storing numerical values from 127 to -128. Bytes are a convenient datatype for sending information to and from the serial port and for representing letters in a simpler format than the char datatype. The first time a variable is written, it must be declared with a statement expressing its datatype. Subsequent uses of this variable must not reference the datatype because Processing will think the variable is being declared again.

数据类型为字节, 8 位信息存储数值从127-128。字节是一种方便的数据类型, 用于向串行端口发送信息, 并用于以比 char 数据类型更简单的格式表示字母。第一次写入变量时, 必须用表达其数据类型的语句声明它。此变量的后续使用不能引用该数据类型, 因为处理将认为该变量正在再次声明

Syntax

语法

byte var

byte var = value

Parameters

参数

var variable name referencing the value
引用值的变量名
value a number between 127 to -128

范围在127到-128之间

Related

相关

int
float
boolean


最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。