Skip to content

Support binary, octal and hex values in argument conversion with int type #3909

Closed

Description

@pekkaklarck

If we have an argument like arg: int, we convert strings like 42 and -1 to integer. In some contexts it would be convenient to represent numbers using binary, octal or hexadecimal values. Because these values cannot be reliable separated from normal integers, we should require using the common 0b, 0o and 0x prefixes. For example, integer 170 could be represented as 0b10101010, 0o252 or 0xAA.

Notice that similar support was added to Convert To Integer and Should (Not) Be Equal As Integers (#808) and to number variables (e.g. ${0xAA), #835) already in RF 2.6. Once we enhance argument conversion like this (and don't need to support Python 2), we can simply add type hints to the aforementioned keywords to get conversion done automatically. Without this enhancement we'd need to keep the custom code in the aforementioned keywords.

Activity

  1. added this to the v4.1 milestone on Mar 26, 2021
  2. pekkaklarck commented on Mar 26, 2021

    @pekkaklarck
    MemberAuthor

    The format should be space-insensitive to allow using e.g. 0b 1010 1010 and case-insensitive to support both 0xFF and 0xff. I'm not sure should we allow the prefix to be case-insensitive and allow both 0b10 and 0B10, but I think we do that elsewhere so for consistency reasons that would be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions