# Data Formats in Natural

**URL:** <https://techcommunity.softwareag.com/t/data-formats-in-natural/78708>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [August 7, 2008, 7:02pm UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708 "2008-08-07T19:02:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ROHAN\_LOBO](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@ROHAN\_LOBO](https://techcommunity.softwareag.com/u/ROHAN_LOBO)\
**Post date:** [August 7, 2008, 7:02pm UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/1 "2008-08-07T19:02:09Z")

</div>

Hi All,

I have 2 questions about floating and packed data formats in natural :

```
 1. Here We generally use packed(P) and numeric(N) formats to define numeric digits with decimal point that is floating point. But when natural has Floating point format(F), why cannot we use F format?

 2. In my program i define a field with P10. Then inside the program i will move value of length 7 bytes to field. So internally what will be the result i mean to say how many bytes it will store? Is it N/2 +1 ?

```

Where i can get all this information in software ag website?

Thanks,  
Rohan.

---

<div class="post-metadata">

**Author:** ![Aldo\_Teusch](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/aldo_teusch/32/87_2.png) [@Aldo\_Teusch](https://techcommunity.softwareag.com/u/Aldo_Teusch)\
**Post date:** [August 7, 2008, 7:11pm UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/2 "2008-08-07T19:11:56Z")

</div>

Hi Rohan,

Did you try [http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/pg/pg\_defi\_dv.htm#Format\_Length\_Def](http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat424mf/pg/pg_defi_dv.htm#Format_Length_Def) ?

Aldo

---

<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:** [August 8, 2008, 11:50am UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/3 "2008-08-08T11:50:37Z")

</div>

> [@ROHAN LOBO](#):
>
> But when natural has Floating point format(F), why cannot we use F format?

You have to think about the purpose. Here’s a rule of thumb: You should use floats for scientific and for some statistical calculations. But for pure business calculations (like calculating VAT or so) you should use Numeric/Packed Fields.

We got a similar discussion here:

[http://tech.forums.softwareag.com/viewtopic.php?t=7117](http://tech.forums.softwareag.com/viewtopic.php?t=7117)

---

<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:** [August 10, 2008, 9:59am UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/4 "2008-08-10T09:59:58Z")

</div>

One thing to mention:

Format N is a “display” format, so when using N-fields in computations, Natural will always convert it to a P internally, do the computation, convert it back to N.

---

<div class="post-metadata">

**Author:** ![ROHAN\_LOBO](https://avatars.discourse-cdn.com/v4/letter/r/df705f/32.png) [@ROHAN\_LOBO](https://techcommunity.softwareag.com/u/ROHAN_LOBO)\
**Post date:** [August 11, 2008, 11:30am UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/5 "2008-08-11T11:30:07Z")

</div>

Thanks winter…

```
    So floating can be used only for scientific calculations. and N is only for display format. so if i define a variable = N7, internally P will be 7/2 +1 = 3.5 +1 = 5 bytes. Please correct if i am wrong?

```

---

<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:** [August 11, 2008, 1:05pm UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/6 "2008-08-11T13:05:49Z")

</div>

No, I didn’t say (or imply) that, you can use N in computations, otherwise Natural would disallow it, you should just be aware of the implications.

If you use a field in arithmetic operations a lot, and only output it once, using P makes sense because it saves Natural the overhead of converting from N to P to N every time.

As for your other question, a format “N” field will always occupy the number of bytes equal to the number of digits specified. So a N7.2 field will occupy 9 bytes.

Your formula for packed fields is wrong, it isn’t (n/2) + 1 but (n + 1) / 2.  
So a P7 field occupies (7+1)/2 = 4 bytes, not 5.

---

<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:50pm UTC](https://techcommunity.softwareag.com/t/data-formats-in-natural/78708/7 "2021-04-02T14:50:43Z")

</div>


