Ab Initio - 以左对齐方式格式化数字

发布于 2024-08-29 21:58:29 字数 210 浏览 2 评论 0原文

我在 Ab Initio 中有一个要求,将数字格式化为左对齐。我不应该使用字符串转换(因为默认情况下字符串是左对齐的),因为它可能会导致另一端的兼容性问题。

例如,如果我的字段有 7 个字节长度,并且我只得到两位数字作为输入,那么这两位数字应该进入我的字段的前两个字节(左对齐),而不是最后两个字节。

那么,Ab Initio 中是否有任何内置函数可以将数字格式化为左对齐?

I have a requirement in Ab Initio to format a number in left alignment. I shouldn't be using String conversion (as Strings are left aligned by default), as it might cause compatibility problems in the other end.

For example, if my Field has 7 bytes length, and I'm getting only two digits as my input, then these two digits should go into the first two bytes of my field (left aligned), instead of the last two bytes.

So, is there any in-built function in Ab Initio, that can format a number as left aligned?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北斗星光 2024-09-05 21:58:29

您可以将其转换为字符串并让它运行。 Ab Initio 将自动在字符串和十进制之间进行转换。此外,这两种类型的物理表示是相同的。

如果您尝试使用非基于 ASCII 的格式(int、float 等),我认为没有内置函数可以实现此目的,您可能需要做一些粗略的操作,例如将其转换为 void 类型然后使用 hex_to_string() 转换为字符串类型以保留确切的位,然后用空格向右填充。

You can convert it to string and let it ride. Ab Initio will automatically convert between string and decimal. Also, the physical representation will be the same for these two types.

If you are trying to use a non-ascii based format (int, float, etc.) I don't think there is a built-in function for this and you will probably have to do something rough like cast it to a void type then to a string type using hex_to_string() to preserve the exact bits and then right pad with spaces.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文