![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Как преобразовать 48-битное число? [D7, XP]
Zilog © (2006-07-04 14:30:00)Как преобразовать 48-битное число? При том, что мантисса кодируется 36-ю битами, а экпонента 12-ю.
например, вот это число равно еденице (1): 70368744179712
а вот это минус еденице (-1): -140737488353281
Zilog (2006-07-05 11:59:00) [21]99999999A7FC -0.1
AA19C47747E5 -0.00000001
8000000007FF -1
B97247454800 -1.1024
A00000000800 -1.5
800000000800 -2
B00000000801 -2.5
9C0000000806 -100
82DCCBFB1809 -1001.1001
800000000809 -1024
80000000080B -4096
BFFF9999A80C -4096.1
80000000080D -16384
BFFFFFF9780E -16384.0001
8A432EAE081A -123456789.123456789
MBo (2006-07-05 11:47:00) [22]>даа... с отрицательными числами вообще беда какая-то...
еще несколько отрицательных покажи
Zilog (2006-07-05 11:44:00) [23]даа... с отрицательными числами вообще беда какая-то...
эх. надо было в математику лучше учить... :)
вот это может помочь делу?
http://www.quadibloc.com/comp/cp02.htm
MBo (2006-07-05 11:30:00) [24]uses math
Zilog (2006-07-05 11:28:00) [25]>>Power(2, e);
Power - это что?
MBo (2006-07-05 11:23:00) [26]Вот это проходит, кроме числа -3
procedure TForm5.Button1Click(Sender: TObject);
var
i64, M: Int64;
e: SmallInt;
x: Double;
Sign : Integer;
begin
i64 := StrToInt64('$' + Edit1.Text);
M := i64 shr 12;
Sign := 1;
if (M and $800000000) <> 0 then begin
M := M - $400000000;
Sign := - 1;
e:= (i64 and $FFF) - $7FF - 34;
end else
e:= (i64 and $FFF) - $800 - 34;
x := Sign * M * Power(2, e);
Label1.Caption := Format('%x %d %f',[M, e, x]);
end;
Zilog (2006-07-05 09:56:00) [27]up
Zilog (2006-07-04 17:52:00) [28]пожалуйста:
0.25 = 4000000007FE
0.5 = 4000000007FF
0.75 = 6000000007FF
2 = 400000000801
3 = 600000000801
4 = 400000000802
5 = 500000000802
100 = 640000000806
1048576 = 400000000814
-2 = 800000000800
-3 = A00000000801
-0.5 = 8000000007FE
MBo (2006-07-04 16:57:00) [29]Ну тогда давай больше чисел, и лучше сразу в hex, например, из набора:
0 0.25 0.5 0.75 2 3 4 5 100 1048576
-2 -3 -0.5
Zilog (2006-07-04 16:50:00) [30]>>MBo © (04.07.06 14:36) [1]
1) преобразовать в "человеческий" вид. ЧТо бы можно было отобразить читабельное число, а не набор цифр.
2) подозреваю, что в 40-ом бите
3) Судя по международному стандарту, расклад такой:
Знак (48 бит), Экспонента(47..37), Мантисса(36..0)
4) неизвестно, но скорее всего оно не нормализовано, т.е. окажется вида 1234.567, например.
tsa (2006-07-04 15:44:00) [31]Zilog © (04.07.06 14:30)
смотри крайние значения, анализируй
если адрес такой переменной знаешь, то грузи частями мантису/порядок
в asm вставке
MBo (2006-07-04 15:42:00) [32]первое число в Hex
400000000800
второе
8000000007FF
Так что пока непонятно...
MBo (2006-07-04 15:33:00) [33]>Этой информации достаточно?
нет
Zilog (2006-07-04 14:51:00) [34]Numerical Values
PMAC can store and process numerical values in many forms, with both fixed-point and floating-point values. The Motorola 56000 DSP that acts as the PMAC CPU is a fixed-point processor with built-in 24- bit and 48-bit arithmetic capability (plus a 56-bit accumulator). However, the PMAC firmware implements a full set of floating-point routines.
Internal Formats
The internal servo, interpolation, and commutation routines all operate with fixed-point arithmetic, 24-bit and 48-bit, for maximum speed. The user motion and PLC programs, use floating-point arithmetic for maximum range and generality. Even when reading from and/or writing to fixed-point registers, the intermediate formats are all floating-point values. The only exception to this rule is the new compiled PLC programs; in a statement containing only L-variables and integer constants, the intermediate format is signed 24-bit integer. Refer to the section on compiled PLCs under the Writing a PLC Program section of this manual for more details. The general floating-point format is 48 bits long, with a 36-bit mantissa and a 12-bit exponent. This provides a range of +2+2047, or +3.233 x 10+616, which should provide sufficient range for any foreseeable
uses on the card.
Receiving Values
Constant values sent from the host as part of command lines are sent as ASCII text, either as decimal values or hexadecimal values. Hexadecimal values must be preceded by a $ character; they must be
unsigned, and they cannot include fractional values. Decimal values can be positive or negative, and can include fractional values. The PMAC value interpreter does not support exponential notation, and it is limited to passing through values in the range +2+35, or +3.43 x 10+10. Values outside this range are truncated to the maximum or minimum values of the range.
Этой информации достаточно?
MBo (2006-07-04 14:36:00) [35]Во что преобразовать?
Где знак кодируется?
Что идет сначала - мантисcа или экспонента?
Экспонента смещенная или нет?
Как нормализована мантисса?