Thank you!
 
 One more question. I want to convert an integer into a byte-array containing its bytes. In my use case it was the return value of the nano-count, but the question is general: how can I get the bytes of an integer.
 
 For floats there are primitives like float>bits and double>bits, and for integers there is >le and >be, but for the latter two I need to specify the size in bytes. Is there a way to ask an integer how many bytes it occupies? Because from the documentation it's not clear at all how many bytes nano-count would return, and it may vary depending on the current platform. What am I missing?
 
23.03.2020, 03:13, "Doug Coleman" <doug.cole...@gmail.com>:
You could do this:
 
: SODIUM_SIZE_MAX ( -- x ) cell-bits on-bits ;
 
where cell-bits gives 32/64 and on-bits turns them to ones.
 
 
On Sun, Mar 22, 2020 at 6:44 PM Alexander Ilin <ajs...@yandex.ru> wrote:
Hello!

  I'm creating the sodium library FFI for Factor, and I found the following definition in the Sodium C headers:

#define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B))
#define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX)

  I think SODIUM_SIZE_MAX is used as platform-dependent macro constant, which represents a maximum value for array sizes and similar memory limits.
  It'll have the max value of the size_t type, which is either 16-bit, 32-bit or 64-bit depending on the compilation target platform.

  How should I define the SODIUM_SIZE_MAX constant in Factor?

---=====---
 Александр



_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk
,,

_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

 
 
---=====---
Александр
 
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to