Skip to main content
added 110 characters in body
Source Link
Martynas
  • 538
  • 3
  • 10
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to do like this:

float CS = 30.10;
au16data[0]= (int)(CS*100);//3010.00 > 3010

And for better way use :

float auFloatData[30]; // 
...
auFloatData[0]=Current_Value1[0];
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to do like this:

float CS = 30.10;
au16data[0]= (int)(CS*100);//3010.00 > 3010
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to do like this:

float CS = 30.10;
au16data[0]= (int)(CS*100);//3010.00 > 3010

And for better way use :

float auFloatData[30]; // 
...
auFloatData[0]=Current_Value1[0];
deleted 38 characters in body
Source Link
Martynas
  • 538
  • 3
  • 10
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to to do like this:

float CS = 30.10;
CS =au16data[0]= CS*100;(int)(CS*100);//3010.00
int Int_CS => (int)CS;/3010
au16data[0] = Int_CS; 
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to to like this:

float CS = 30.10;
CS = CS*100;//3010.00
int Int_CS = (int)CS;/3010
au16data[0] = Int_CS; 
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to do like this:

float CS = 30.10;
au16data[0]= (int)(CS*100);//3010.00 > 3010
added 6 characters in body
Source Link
Martynas
  • 538
  • 3
  • 10
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1;1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to to like this:

float CS = 30.10;
CS = CS*100;//3010.00
int Int_CS = (int)CS;/3010
au16data[0] = Int_CS; 
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1; -0.1 * 100 = -10

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to to like this:

float CS = 30.10;
CS = CS*100;//3010.00
int Int_CS = (int)CS;/3010
au16data[0] = Int_CS; 
  1. Sizes

Integer Types (int, long and long long)

Size of Boolean type is 1 byte(s)

Number of bits in a character: 8 Size of character types is 1 byte Signed char min: -128 max: 127 Unsigned char min: 0 max: 255 Default char is unsigned

Size of short int types is 2 bytes Signed short min: -32768 max: 32767 Unsigned short min: 0 max: 65535

Size of int types is 4 bytes Signed int min: -2147483648 max: 2147483647 Unsigned int min: 0 max: 4294967295

Size of long int types is 4 bytes Signed long min: -2147483648 max: 2147483647 Unsigned long min: 0 max: 4294967295

Size of long long types is 8 bytes Signed long long min: -9223372036854775808 max: 9223372036854775807 Unsigned long long min: 0 max: 18446744073709551615 Note that int and long are the same size and if you want a 64 bit integer then you need to use long long (or unsigned long long).

  1. What do you want to achieve with

.

CS=30.10 // 30.10
Int_CS=int(CS) // 30
FLOAT_CS = (Int_CS-CS)*100 //-10.00 because 30 - 30.10 = -0.1 and -0.1 * 100 = -10.00

CS is already float, why you want to convert it to int and back to float? If value of int is higher than 255 you have to save it in 2 bytes(highByte and lowByte), float is 32bit(4bytes) value.

I think you have to to like this:

float CS = 30.10;
CS = CS*100;//3010.00
int Int_CS = (int)CS;/3010
au16data[0] = Int_CS; 
added 138 characters in body
Source Link
Martynas
  • 538
  • 3
  • 10
Loading
Source Link
Martynas
  • 538
  • 3
  • 10
Loading