Does endianness refer to ordering within a defined array or memory or also the actual memory used? - memory

I'm having trouble expressing my question in words, but I think I can express it visually quite simply. Storing the string abcd, is the difference between Big and Little Endian this:
memory address | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ...
little endian | d | c | b | a |
big endian | a | b | c | d |
Or this:
memory address | 0 | 1 | 2 | 3 | 4 | 5 | 6 | ...
little endian | d | c | b | a |
big endian | a | b | c | d |
My attempt in words: does "endianness" refer to the ordering of bytes within a specific memory "array", where in both cases the array begins at the same point in memory, or does it refer to both the ordering and the actual array used?

Endianness refers to the ordering of bytes used to store a single multi-byte numerical value. The "big endian" system in your second image is storing 4-byte integers unaligned, which no system would normally do.

Related

Ymodem Buffer Start Address

I am looking this source codes to use Ymodem protocole,
https://github.com/STMicroelectronics/STM32CubeF4/blob/master/Projects/STM324xG_EVAL/Applications/IAP/IAP_Main/inc/ymodem.h
But I've a question about that,
Line 65 says to us as in below:
/* /-------- Packet in IAP memory ------------------------------------------\
* | 0 | 1 | 2 | 3 | 4 | ... | n+4 | n+5 | n+6 |
* |------------------------------------------------------------------------|
* | unused | start | number | !num | data[0] | ... | data[n] | crc0 | crc1 |
* \------------------------------------------------------------------------/
* the first byte is left unused for memory alignment reasons
According to this informaton PACKET_DATA_INDEX define 4. But I dont understand this because in the Ymodem includes data in 3th byte, why we choose the 4th byte or SOH is the 0th index of the frame, why we get this as a 1

How to forecast (or any other function) in Google Sheets with only one cell of data?

My sheet:
+---------+-----------+---------+---------+-----------+
| product | value 1 | value 2 | value 3 | value 4 |
+---------+-----------+---------+---------+-----------+
| name 1 | 700,000 | 500 | 10,000 | 2,000,000 |
+---------+-----------+---------+---------+-----------+
| name 2 | 200,000 | 800 | 20,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 3 | 100,000 | 150 | 6,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 4 | 1,000,000 | 1,000 | 25,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 5 | 2,000,000 | 1,500 | 30,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 6 | 2,500,000 | 3,000 | 65,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 7 | 300,000 | 300 | 12,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 8 | 350,000 | 200 | 9,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 9 | 900,000 | 1,200 | 28,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 10 | 150,000 | 100 | 5,000 | ? |
+---------+-----------+---------+---------+-----------+
What I am attempting is to predict the empty columns based on the data that I do have. Maybe just one of the columns that contain data in every row or maybe I should be only focusing on one column that contains data in every row?
I have used FORECAST previously but had more data in the column that I was predicting values for which the lack of data I think is my root problem(?). Not sure if FORECAST is best for this so any recommendations for other functions are most welcome.
The last thing I can add though is that the known value in column E (value 4) is a confident number and ideally it's used in any formula that I end up with (although I am open to any other recommendations).
The formula I was using:
=FORECAST(D3,E2,$D$2:$D$11)
I don't think this is possible without more information. If you think about it, Value 4 can be a constant (always 2,000,000), be dependent on only one other value (say 200 times value 3), or be a complex formula (say add values 1, 2, and 3 with a constant). Each of these 3 models agree with the values for name 1, however they generate vastly different value 4 predictions.
In the case of name 2, the models would output the following for value 4:
Constant: 2,000,000
Value 3: 8,000,000
Sum: 2,489,700
Each of those values could be valid without providing further constraints (either through data points or specifying the kind of model, but probably both).

How to do a goedel numbering for bit strings?

I'm looking for a concept for doing a Gödel numbering for bit strings, i.e. for arbitrary binary data.
Approach 1 (failing): Simply interpret the binary data as data of an unsigned integer.
This fails, because e.g. the two different strings "01" and "001" both represent the same integer 1.
Is there a standard way of doing this? Is 0 usually included or excluded from the Gödel numbering?
The original Gödel numbering used prime numbers and unique encoding of symbols. If you want to do it for strings consisting of "0" and "1", you need positive codes for "0" (say 1) and "1" (say 2). Then numbering of "01" is
21 * 32
while numbering of "001" is
21 * 31 * 52
For longer strings use next prime numbers. However, note that Gödel numbering goals did not include any practical considerations, he simply needed numbering as a tool in the proof of his theorem. In practice for fairly short strings you will exceed range of integers in your language, so you need to use either a language with arbitrary large integers built-in (like Scheme) or a library supporting bignums in language without them built-in.
A super simple solution is to prepend a 1 to the binary data and then interpret the result as an unsigned integer value. This way, no 0-digits get lost at the left side of the bit string.
Illustration how well this works:
One obvious way to order bit strings is to order them first by length and then lexicographically:
+------------+
| bit string |
+------------+
| ε |
| 0 |
| 1 |
| 00 |
| 01 |
| 10 |
| 11 |
| 000 |
| 001 |
| 010 |
| 011 |
| 100 |
| 101 |
| 110 |
| ... |
+------------+
(ε denotes the empty string with no digits.)
Now we add an index number n to this table, starting with 1, and then look at the binary representation of the index number n. We will make a nice discovery there:
+------------+--------------+-------------+
| bit string | n in decimal | n in binary |
+------------+--------------+-------------+
| ε | 1 | 1 |
| 0 | 2 | 10 |
| 1 | 3 | 11 |
| 00 | 4 | 100 |
| 01 | 5 | 101 |
| 10 | 6 | 110 |
| 11 | 7 | 111 |
| 000 | 8 | 1000 |
| 001 | 9 | 1001 |
| 010 | 10 | 1010 |
| 011 | 11 | 1011 |
| 100 | 12 | 1100 |
| 101 | 13 | 1101 |
| 110 | 14 | 1110 |
| ... | ... | ... |
+------------+--------------+-------------+
This works out surprisingly well, because the binary representation of n (the index of each bit string when ordering in a very obvious way) is nothing else than a 1 prepended to the original bit string and then the whole thing interpreted as an unsigned integral value.
If you prefer a 0-based Goedel numbering, then subtract 1 from the resulting integer value.
Conversion formulas in pseudo code:
// for starting with 1
n_base1 = integer(prepend1(s))
s = removeFirstDigit(bitString(n_base1))
// for starting with 0
n_base0 = integer(prepend1(s)) - 1
s = removeFirstDigit(bitString(n_base0 + 1))

Generate random Numbers with Specific need

I am developing Cocos 2D game.
Please Mention Below Arrangement.
---------------------------------|
| | | |
| | | |
---------------------------------|
| | | |
| | | |
---------------------------------|
| | | |
| | | |
---------------------------------|
---------------------------------|
| | | |
| | | |
---------------------------------|
Now, I need to generate numbers between 1-99 in Upper Block so, When user touch the numbers they dropped into below block. And I have to check for is that numbers make any combination of operation(i.e. +,-, *,/) Thus it divided by 10 or not?
For example if user choose numbers like 3,2,7,8 Then I have internally calculated (3 +2 +7 +8 = 20 so 20%10 == 0 so number is divisible by 10 so increase score), Same thing for -, *,/.
Math operator is will be same but I have to decide by some code that what user has think for dragging numbers.
So my question is how to generate that numbers in upper block that most probably support calculation(Any one of +,-,*,/) for combinations of them give dividability by 10?
Numbers are not such like any combinations(Either +, -, * ,/) of them thus they did not give answer which have modulo 0 to 10.
Any help will be appreciated.
You could try an inefficient algorithm. Repeatedly generating numbers then testing to see if they pass your condition
do
{
a = random();
b = random();
c = random();
d = random();
} while( !test(a,b,c,d) );
This simplifies the logic. You do need to ensure that at least some combination will work or you will get an infinite loop.

Entity Relation notation in text

Is there a standard (non-graphical) notation for Entity Relationships?
right now I'm using my own janky notation:
User >> Photo , (1-many)
User > Profile , (1-1 hasOne)
Profile < User , (1-1 belongsTo)
Photo << User , (many-1 belongsTo)
Photo <> Tag , (many-many)
Almost 10 years later and I've also had a hard time finding plaintext standards. Here's what I've found so far (fair warning though, it's mostly graphical standards that happen to work well in text).
First, the common term for describing the cardinality of a relationship between objects is "multiplicity".
This association relationship indicates that (at least) one of the two related classes make reference to the other. This relationship is usually described as "A has a B" (a mother cat has kittens, kittens have a mother cat).
Wikipedia
Though a considerable number of sources also use the term "cardinality".
There's a few good answers about the difference on this SO question about Multiplicity vs Cardinality. I found this one to be pretty succinct:
...a multiplicity is made up of a lower and an upper cardinality. A cardinality is how many elements are in a set. Thus, a multiplicity tells you the minimum and maximum allowed members of the set.
Jim L.
UML's Multiplicity Notation
UML's multiplicity notation works well in text.
+--------------+--------+-----------------------------------------+
| Multiplicity | Option | Cardinality |
+--------------+--------+-----------------------------------------+
| 0..0 | 0 | Collection must be empty |
| 0..1 | | No instances or one instance |
| 1..1 | 1 | Exactly one instance |
| 0..* | * | Zero or more instances |
| 1..* | | At least one instance |
| 5..5 | 5 | Exactly 5 instances |
| m..n | | At least m but no more than n instances |
+--------------+--------+-----------------------------------------+
There seem to be a few variations of this:
Microsoft's Relational Notation
+---------------------------------+---------------------+
| Multiplicity | Cardinality |
+---------------------------------+---------------------+
| * | One to zero or more |
| 1..* | One to one or more |
| 0..1 | One to zero or one |
| 1 | Exactly one |
| Two numbers separated by a dash | a range |
+---------------------------------+---------------------+
IBM's
+------+--------------------+-------------------------------+
| Rose | Software Architect | Description |
+------+--------------------+-------------------------------+
| n | * | Unlimited number of instances |
| 1 | 1 | Exactly 1 instance |
| 0..n | * | 0 or more instances |
| 1..n | 1,,* | 1 or more instances |
| 0..1 | 0..1 | 0 or 1 instances |
+------+--------------------+-------------------------------+
Smartdraw's Martin Style
Chen Style
From what I've read Chen style is the "original format". I commonly see this expressed in text as:
+----------+--------------+
| Notation | Description |
+----------+--------------+
| 1:1 | One to One |
| 1:N | One to Many |
| N:1 | Many to One |
| M:N | Many to Many |
+----------+--------------+
IDEF1X and Others
There's IDEF1x (a NIST standard):
IDEF1X is a method for designing relational databases with a syntax designed to support the semantic constructs necessary in developing a conceptual schema.
That seems to describe the Min-Max / ISO notation (the English link is currently broken but here's a German article) referenced by Wikipedia's Entity–relationship model article which also lists a few other styles of graphical notations, some of which are text-friendly.
The German language article on (min,max) notation also has a useful table comparing UML, Chen, (min,max) and MC (Modified Chen):
+----------------------+-----------------+---------------------------------+-------------+-----------------+----------------------+
| (min,max) [Entity 1] | [UML, Entity 1] | Chen-Notation | MC-Notation | [UML, Entity 2] | (min,max) [Entity 2] |
+----------------------+-----------------+---------------------------------+-------------+-----------------+----------------------+
| (0,1) | 0..1 | 1:1 | c:c | 0..1 | (0,1) |
| (0,N) | 0..1 | 1:N | c:mc | 0..* | (0,1) |
| (0,N) | 1..1 | 1:N + total participation | 1:mc | 0..* | (1,1) |
| (0,N) | 0..* | M:N | mc:mc | 0..* | (0,N) |
| (1,1) | 0..1 | total participation + 1:1 | c:1 | 1..1 | (0,1) |
| (1,N) | 0..1 | total participation + 1:N | c:m | 1..* | (0,1) |
| (1,1) | 1..1 | total part. + 1:1 + total part. | 1:1 | 1..1 | (1,1) |
| (1,N) | 1..1 | total part. + 1:N + total part. | 1:m | 1..* | (1,1) |
| (1,N) | 0..* | total participation + M:N | mc:m | 1..* | (0,N) |
| (1,N) | 1..* | total part. + M:N + total part. | m:m | 1..* | (1,N) |
+----------------------+-----------------+---------------------------------+-------------+-----------------+----------------------+
Why not use the same than in ER-Diagramms:
User 1-n Photos
User 1-1 Profile
Photo n-1 User
and so on. But I never heard of an official plaintext standart.
There is software available that transforms plain text descriptions into visual ER diagrams.
For instance erd uses the following notation:
Cardinality Syntax
0 or 1 ?
exactly 1 1
0 or more *
1 or more +
Examples:
Person *--1 `Birth Place`
Artist +--? PlatinumAlbums
Check also this list of similar tools.
However, none of these could be called a standard.

Resources