Show Posts
Pages: [1]
1  Products / Arduino Due / Re: Serial.print() of a 64-bit DOUBLE on: April 29, 2013, 10:07:43 am
robtillaart, thanks for your great code

i test with uint64_t a = 4294329243;

it's can display in DEC, BIN, OCT, HEX all correct.

thank you very much.   smiley

extra code to append to for 1.0x print.cpp
Code:
#ifdef SUPPORT_LONGLONG

size_t Print::println(int64_t number, int base)
{
  size_t n = 0;
  n += print(number, base);
  n += println();
  return n;
}

size_t Print::print(int64_t number, int base)
{
  size_t n = 0;
  if (number < 0)
  {
    write('-');
number = -number;
n++;
  }
  n += print((uint64_t)number, base);
  return n;
}

size_t Print::println(uint64_t number, int base)
{
  size_t n = 0;
  n += print((uint64_t)number, base);
  n += println();
  return n;
}

size_t Print::print(uint64_t number, int base)
{
  size_t n = 0;
  unsigned char buf[64];
  uint8_t i = 0;

  if (number == 0)
  {
    n += print((char)'0');
    return n;
  }
  
  if (base < 2) base = 2;
  else if (base > 16) base = 16;

  while (number > 0)
  {
    uint64_t q = number/base;
    buf[i++] = number - q*base;
    number = q;
  }
  
  for (; i > 0; i--)
    n += write((char) (buf[i - 1] < 10 ?
      '0' + buf[i - 1] :
      'A' + buf[i - 1] - 10));
 
   return n;
}
#endif

additional code for 1.0x print.h
Code:
// uncomment next line for int64 support
#define SUPPORT_LONGLONG

....

#ifdef SUPPORT_LONGLONG
size_t println(int64_t, int = DEC);
size_t print(int64_t, int = DEC);
size_t println(uint64_t, int = DEC);
size_t print(uint64_t, int = DEC);
#endif

2  Products / Arduino Due / Re: ASYMMETRIC ENCRYPTION ARDUINO DUE on: March 10, 2013, 09:57:13 am
I looking for Asymmetric Encryption on Arduino too.

please donate any example package (.c, .ino or .pde format)

Thank you ^^

pumipath@gmail.com
Pages: [1]