64bits long and 64bits double

Hi!
Anyone know if is possible to declare values ??64bit (long64 and double64).

Thanks

You can use int64_t and uint64_t. Be careful, though, if you do much manipulation with them they will gobble up program memory space. 64-bit doubles don't exist AFAIK.

As a side note, it would be fascinating to learn what project requirements you have that make 32-bit double's insufficient!

You can use the syntax:

long long x; // 64-bit integer
long double y;  // "long" double?

That compiles OK.

However a disassembly shows that the "long double", "double" and "float" all generate a 4-byte number. So don't get too excited. (Doubles are normally 8 bytes, not 4).

On the other hand, "int", "long" and "long long" all generate code for different sized variables. As maniacbug said, however, you very quickly run out of memory using long long, because it takes a lot of instructions to do something simple with one, like adding 1 to it. Basically since it is a byte-oriented processor it take 8 times as much work to do something with a long long than a byte.

1 Like

you can use - long long x;
but AFAIK the arduino does not support printing of it directly, so you must work around it (see below)

have a look at - avr-libc: <stdint.h>: Standard Integer Types

long long x = 999999999999LL;  // note the double LL 

void setup()
{
  Serial.begin(115200);
  Serial.println("I am Arduino"); 
  char buffer[100];
  sprintf(buffer, "%0ld", x/1000000L); 
  Serial.print(buffer);  
  sprintf(buffer, "%0ld", x%1000000L); 
  Serial.println(buffer);  
}

void loop() {}

Be aware that the size of your sketch grows very hard when using this datatype -> Binary sketch size: 12906 bytes (of a 30720 byte maximum)

I did not found a "64 bit float/double" on arduino.

I need those types:

short > 16bits
int > 32bits
float > 32bits
long > 64bits
double > 64bits

maniacbug:
You can use int64_t and uint64_t. Be careful, though, if you do much manipulation with them they will gobble up program memory space. 64-bit doubles don't exist AFAIK.

As a side note, it would be fascinating to learn what project requirements you have that make 32-bit double's insufficient!

Im making a JavaVM :wink:

For now (=P), memory is not problem
I will try your codes guys, thanks :wink:

robtillaart:
you can use - long long x;
but AFAIK the arduino does not support printing of it directly, so you must work around it (see below)

have a look at - avr-libc: <stdint.h>: Standard Integer Types

long long x = 999999999999LL;  // note the double LL 

void setup()
{
  Serial.begin(115200);
  Serial.println("I am Arduino");
  char buffer[100];
  sprintf(buffer, "%0ld", x/1000000L);
  Serial.print(buffer); 
  sprintf(buffer, "%0ld", x%1000000L);
  Serial.println(buffer); 
}

void loop() {}



Be aware that the size of your sketch grows very hard when using this datatype -> Binary sketch size: 12906 bytes (of a 30720 byte maximum)

I did not found a "64 bit float/double" on arduino.

Thanks I was looking for this too :wink: