# Packed Decimal Field - Can we turn off Sign Bit?

**URL:** <https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes, Natural-on-Windows-Unix\
**Created:** [March 26, 2009, 11:59am UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603 "2009-03-26T11:59:56Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![senorita](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@senorita](https://techcommunity.softwareag.com/u/senorita)\
**Post date:** [March 26, 2009, 11:59am UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/1 "2009-03-26T11:59:56Z")

</div>

Hi,

May I know whether is it possible to turn off the sign bit for Packed Decimal field say a field declared as #sal (p8.2)?

I tried using SG=off, but gives NAT1125 error.

Thanks!

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 26, 2009, 12:58pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/2 "2009-03-26T12:58:04Z")

</div>

SG doesn’t turn off the half byte for the sign. It only turns off the printing of the sign.

example:

```auto
define data local
1 #sal (P8.2) init <1>
end-define
write #sal (SG=OFF)
add 1 to #sal
write #sal (SG=OFF)
end
```

---

<div class="post-metadata">

**Author:** ![senorita](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@senorita](https://techcommunity.softwareag.com/u/senorita)\
**Post date:** [March 26, 2009, 2:02pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/3 "2009-03-26T14:02:30Z")

</div>

Hi Matthias,

1. #sal (p8.2)

input #sal

# Output - It allows user to enter 12 digits

1. #sal (n5)  
input # sal

# Output - It allows user to enter 6 digits

1. #sal (n5)  
input #sal (sg=off)

# Output - It allows user to enter only 5 digits (i.e as per it’s length)

1. #sal(p8.2)  
input #sal(sg=off)

# Output - It still allows user to enter 12 digits,where as I wanted to restrict user to 11 digits. Is this possible?

Thanks!  
Does this mean

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 26, 2009, 2:50pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/4 "2009-03-26T14:50:36Z")

</div>

> [@senorita](#):
>
> 1. #sal(p8.2)  
> input #sal(sg=off)
> 
> Output - It still allows user to enter 12 digits

On my system (Solaris), this input statement allows 11 digits (to have enough space for the decimal point). So everything is Ok, isn’t it? :?:

---

<div class="post-metadata">

**Author:** ![senorita](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@senorita](https://techcommunity.softwareag.com/u/senorita)\
**Post date:** [March 26, 2009, 3:12pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/5 "2009-03-26T15:12:22Z")

</div>

Hi Matthias,

Oh is it. I am using Software AG Natural Studio Version 6.3.4 on windows and I get NAT1125 error as soon as I enter the 11th digit.

Thanks!

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [March 26, 2009, 5:03pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/6 "2009-03-26T17:03:30Z")

</div>

Education, Education, Education.

P8.2 means a variable with eight digits before and two digits after a decimal point.

I am running 6.3.5 (do not have .4 on machine anymore.

You should not be getting a Nat 1125 when entering an 11th digit. For example, I can enter 12345678.123 Natural will ignore the 3 at the end.

HOWEVER, you cannot enter 123456789.1 This gets you the 1125, which is proper. Natural feels it cannot eliminate anything before the decimal point.

Similarly, Natural will not allow you to MOVE a P9.2 variable to a P8.2 variable if the P9.2 variable has a value such as 123456789.12. Natural will allow such a MOVE (NAT 1305).

All of which makes perfect sense.

steve

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 26, 2009, 5:14pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/7 "2009-03-26T17:14:08Z")

</div>

> [@Steve Robinson](#):
>
> All of which makes perfect sense.

The only thing which doesn’t make perfect sense to me: SG=OFF doesn’t cause an error, if the value is negative. You can even enter a negative value without getting an error. But OK, it’s documented in the natural parameter reference.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [March 26, 2009, 5:40pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/8 "2009-03-26T17:40:07Z")

</div>

Yes. For both Input and Output, SG only refers to the extra space; it never refers to whether a negative value is valid or not.

I always thought the documentation should have more of a warning than it does with regard to this parameter.

With SG=OFF, a negative number will be written without a sign ; and, as observed, on INPUT with SG=OFF, you can still enter a negative number.

I have seen code where negative values were to be treated as invalid. The programmer used SG=OFF, and did not have a validation test such as

IF #INPUT LT 0 …

A maintenance programmer had spent 3 days trying to find a bug that resulted from having a negative value in #INPUT. Probably went to the same class as the original programmer ☹

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [March 26, 2009, 5:50pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/9 "2009-03-26T17:50:02Z")

</div>

> [@Steve Robinson](#):
>
> on INPUT with SG=OFF, you can still enter a negative number.

And that’s different to the logic of NL.

Try this:

```auto
define data local
01 #sal (P8.2)
end-define
input #sal (SG=OFF NL=3.1)
write #sal
end
```

-123 is OK  
1234 causes NAT1125

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [March 26, 2009, 6:08pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/10 "2009-03-26T18:08:10Z")

</div>

You get the same error message with SG=ON NL=3.1 when you try to enter 1234.

This is correct. NL=3.1 checks to make sure there are not greater than three digits before the decimal point. The NAT1125 has nothing to do with SG.

steve

---

<div class="post-metadata">

**Author:** ![senorita](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@senorita](https://techcommunity.softwareag.com/u/senorita)\
**Post date:** [March 27, 2009, 8:54am UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/11 "2009-03-27T08:54:55Z")

</div>

Hi Steve!

Greetings!  
As always thanks for your help.

I always thought NAT1125 is related to SG, hence this question.Thanks for the clarification though.

But I would like to address an issue. The query I posted is under “Natural Baiscs on Mainframes”, there is nothing harm in learning something new and clarifying doubts right?. Hence would appreciate if you can be little easy/placid with your words/replies. I am an expert on Cobol-DB2, and learning Natural and being new with the technology such queries are bound to arise. And again I post queries when I dont get some quick answers from my peers,reference documents and self-trial. These may sound silly to people/you but may not necessarily be silly for a beginner.

Thanks!  
Good Day.

---

<div class="post-metadata">

**Author:** ![Curtis\_Pew](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@Curtis\_Pew](https://techcommunity.softwareag.com/u/Curtis_Pew)\
**Post date:** [March 31, 2009, 7:53pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/12 "2009-03-31T19:53:11Z")

</div>

I think Steve

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:51pm UTC](https://techcommunity.softwareag.com/t/packed-decimal-field-can-we-turn-off-sign-bit/80603/13 "2021-04-02T14:51:43Z")

</div>


