Dev study and notes

아두이노 int 타입 범위. JAVA 의 int 차이. 타입 범위 본문

errorSolution

아두이노 int 타입 범위. JAVA 의 int 차이. 타입 범위

devlunch4 2021. 3. 26. 13:43
반응형

팀원과 아두이노를 이용하여 센서정보 기록을 프로젝트 연동하다가 해당 센서의 기록  주기를 설정 작업중이였다.

30000 이면.. 30초 간격인데.. 그이상 에러가 되고있다.

 

알아보니 아두이노의 int 타입의 범위와 JAVA의 int 타입이 다르다.

정확히는 아두이노의 안드로이드 버전에 따라서 16bit(2byte) / 32bit(4byte) 에 따른 범위가 다르기 때문이다.

 

공식문서를 통해 알게 되었다.

 

간략히 요약하면

java :  int type range = -2147483648 to 2147483647 [2^31]

arduino :  int type range = -32,768 to 32,767 [2^15]

 

 

참조 : 아두이노 공식문서 , 자바 공식문서

www.arduino.cc/reference/ko/language/variables/data-types/int/

 

int - 아두이노 참조

예제 코드 This code creates an integer called 'countUp', which is initially set as the number 0 (zero). The variable goes up by 1 (one) each loop, being displayed on the serial monitor. int countUp = 0; //creates a variable integer called 'countUp' voi

www.arduino.cc

docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

 

Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)

The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. See Java Language Changes for a summary of updated

docs.oracle.com

 

반응형
Comments