contributed by < linD026
>
linux2021
struct bn
FORMAT_STRING
Linux Programmer's Manual - printf(3)
The unsigned int argument is converted to unsigned octal (o), unsigned decimal (u), or unsigned hexadecimal (x and X) notation.
會在 bn_to_str
函式 UTPYE
轉換至 char
實用到:
bn_from_int
把 UTYPE_TMP 型態的 i 儲存進 struct bn 。
其中原程式碼對於儲存位置是假定為 little-endian ,亦即 n->array[0] = i; 等操作。
然而電腦也有可能為 big-endian ,因此我在儲存前先做了處理。
所謂的 big endian 是指資料儲存於記憶體的方向與記憶體位址不同。也就是說資料的最高位元組是放置在低記憶體位址。
而 little endian 則是兩者方向相同。
至於 array[0] 為何就會是低記憶體位址?
規格書有定義到:
6.5.8 Relational operators
5 If the objects pointed to are members of the same aggregate object, pointers to structure members declared later compare greater than pointers to members declared earlier in the structure, and pointers to array elements with larger subscript values compare greater than pointers to elements of the same array with lower subscript values.
而關於實作部份,則會涉及 Memory Address Decoding 。