Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5965729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:40:38+00:00 2026-05-22T19:40:38+00:00

Alphanumeric movement to Numeric variable caused unexpected results. Here is the code fyr: DATA

  • 0

Alphanumeric movement to Numeric variable caused unexpected results. Here is the code fyr:

  DATA DIVISION.                                 
  WORKING-STORAGE SECTION.                       
  01  WS-VAR-STR       PIC X(3) VALUE SPACES.                
  01  WS-VAR-NUM       PIC 9(3) VALUE ZEROES. 
  PROCEDURE DIVISION.                            
      MOVE '1'         TO WS-VAR-STR                  
      MOVE WS-VAR-STR  TO WS-VAR-NUM
      DISPLAY 'STRING > ' WS-VAR-STR '< MOVED > ' WS-VAR-NUM '<'

      IF WS-VAR-NUM >= 40 AND <= 59
         DISPLAY 'INSIDE IF >' WS-VAR-NUM
      ELSE 
         DISPLAY 'INSIDE ELSE >' WS-VAR-NUM
      END-IF
      GOBACK                                     
      .  

    OUTPUT:
    STRING > 1  < MOVED > 1 0<
    INSIDE ELSE >1 O

The result is bizzare and want to figure why ‘1’ is moved as ‘1 0’ into numeric variable and interestingly there was NO issue in conditioning it as well. Do share your views. Thanks for your interest.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:40:40+00:00Added an answer on May 22, 2026 at 7:40 pm

    Basically you have done an illegal MOVE. Moving alphanumeric to numeric fields is valid
    provided that the content of the alphanumeric field contains only numeric characters.
    This reference
    summarizes valid/invalid moves.

    What were you expecting as a result?

    Moves of alphanumeric fields into numeric ones are done without
    ‘conversion’. Basically you just dropped a one digit followed by two spaces into a numeric field. the ‘1’ was ok, the two spaces
    were not. The last two bytes of WS-VAR-NUM contain spaces.

    But wait… why is the last character a zero? The answer to this is a bit more complicated.
    Items declared as PIC 9 something are represented in Zoned Decimal.
    Each digit of a zoned decimal number is represented by a single byte.
    The 4 high-order bits of each byte are zone bits; the 4 high-order bits of the low-order byte represent
    the sign of the item. The 4 low-order bits of each byte contain the value of the digit. The key here
    is where the sign is stored. It is in the high order bits of the last byte. Your declaration did not
    include a sign so the MOVE statement blows away the sign bits and replaces them with default
    numeric high order bits (remember the only valid characters to MOVE are digits – so this
    patch process should always yield a valid result). The high order bits of an unsigned zoned decimal
    digit are always HEX F. What are the low order bits of the last byte? A space has an ebcdic HEX value of 40. A zero is HEX F0. Since the MOVE statement “fixes” the sign automatically, you end up with HEX F0 in the low order digit, which happens to be, you guessed it, zero. None of the other ‘digits’ contain sign bits so they are left as
    they were.

    Finally, a DISPLAY statement converts zoned decimal fields into their equivalent character representation
    for presentation: Net result is: ‘1 0’.

    BTW The above discussion is how it works out on an IBM z/OS platform – other character sets (eg. ASCII) and/or other platforms may yield different results, not because IBM is doing the wrong thing, but because the program is doing an illegal MOVE and the results are essentially undefined.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below code in vb.net for validating alphanumeric characters, It is working fine
Is there any syntax query in mysql phpmyadmin to trim alphanumeric(varchar) data? Here's how
Here are the requirements: Must be alphanumeric, 8-10 characters so that it is user
I found this code for alphanumeric check (Letters, numbers, spaces or underscores) but I
I'm running a select that returns alphanumeric results, e.g: ABC-1 ABC-2 ABC-10 SAM-1 SAM-2
how to split the numeric values from alphanumeric string value using java script? for
Here are my requirements: 1-80 characters These characters are allowed: alphanumeric spaces _ (
I am working on an application wherein i need to compare 10^8 entries(alphanumeric entries).
One of the most common kinds of database table has an alphanumeric code and
How can I always generate a 17 character unique alphanumeric data with c#.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.