Hi,
The negatives are stored with a sign in the rightmost position of the field - the sign is normally a letter and is dependent upon the rightmost digit in the value. This sounds more confusing than it is and you don't really need to know too much about it in practice.
To enter negative values in packed fields you could use DFU or SQL or any other data entry tool and just enter the value as a normal negative - the system will handle the packing and unpacking for you.
Regards,
Martin Gilbert.
////////////////////////////
Hi,
Expanding Martin explanation, to store a packed field the format in hex for number 12345 will be:
'12345F'
For -12345 it will be :
'12345D'
Well, the last byte ('5D') will represent character ')' but if you put this negative number in screen it will be displayed like :
'1234N'
because system will convert hex '12345D' to hex 'F1F2F3F4D5' and 'D5' is letter 'N'
Wilson
---
To expand on Wilson's answer... in his example it will only
display an N if you display the value with without consideration
for the sign. use a display field that allows for negative numbers
and you can display '-12345'.
Steve
Last Wiki Answer Submitted: July 29, 2009 2:54 pm by WilsonAlano2,385 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Hi thanks for the feed back. But i still have a doubt. When i tried to enter a negative value into a packed field in a PF (like -1234.56) the keyboard is getting locked for entering – sign. Please explain how to avoid this. thanks again
Enter your number (ie., 1234.45), then use the Field Minus key. I use Client Access, and the default for this key is the minus key on the 10-key pad.
Having done this the field will display with a non-numeric character in the right-most position of the field, but will show as 1234.45- when re-displayed on the screen.
If you use DFU or any editor, it will transalte, as Leo says.
If you’re editing the PF at byte level, then check the manuals for the character map or write yourself a byte dump and understand which bit is the sign bit in the field.
A character ‘D’ for instance is merely a 5 with its sign bit set to negative, ditto for A, B etc. F indicates all bits set, which is taken as positive. I forget the other defaults for 1110, 1100 1101 etc –
Mainly – just use an editor and let the compilers take the strain..
Hi thanks for the feed back. But i still have a doubt. When i tried to enter a negative value into a packed field in a PF (like -1234.56) the keyboard is getting locked for entering – sign. Please explain how to avoid this. thanks again
Ram
Hi Ram,
To allow enter a sing in a DSPF you must use a “keyboard shift” ‘S’ or ‘Y’ if you will use an edit code or edit word.
The minus sign must be entered after the number. 1234.45-
Regards
Wilson
Enter your number (ie., 1234.45), then use the Field Minus key. I use Client Access, and the default for this key is the minus key on the 10-key pad.
Having done this the field will display with a non-numeric character in the right-most position of the field, but will show as 1234.45- when re-displayed on the screen.
Leo Burkett
Ignore the sign at the bit level.
If you use DFU or any editor, it will transalte, as Leo says.
If you’re editing the PF at byte level, then check the manuals for the character map or write yourself a byte dump and understand which bit is the sign bit in the field.
A character ‘D’ for instance is merely a 5 with its sign bit set to negative, ditto for A, B etc. F indicates all bits set, which is taken as positive. I forget the other defaults for 1110, 1100 1101 etc –
Mainly – just use an editor and let the compilers take the strain..