问题标签 [number-systems]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
1116 浏览

algorithm - how to find total number of numbers whose binary representation is palindrome?

What is the best approach to find the total number of numbers between two given numbers whose binary representation is palindrome? The problem I am trying to solve is here on spoj http://www.spoj.com/problems/BINPALI/

0 投票
1 回答
127 浏览

number-systems - 当给出负位置值时,如何执行 base-5 加法?

在具有数字 T,M,0,1,2 并且它们的位值分别为 -2,-1,0,+1,+2 的以 5 为基数的数字系统中,则:

  1. 可以形成的最大十进制值是多少?
  2. (MT01) + (1TM0) = ??

这个问题是在一个VLSI公司的招聘测试中给出的..请提出答案..

0 投票
1 回答
89 浏览

binary - 将二进制数据存储在数字中的最佳方法是什么?

我想知道是否可以将二进制数据存储在一个数字中,以及如何将尽可能多的二进制数据存储在一个数字中。

例如,假设我想将以下文本存储在一个数字中:

Lorem ipsum dolor sit amet, consectetur adipiscing elit。Donec egestas nunc eget rhoncus blandit。

二进制形式是:

现在,如果我将其转换为数字,我会得到:2.15146353486 * 10^16

将其转换回二进制是问题所在,我得到00000010.

现在显然我不知道我在这里做什么,所以请理解这不是“为什么这不起作用?” 问题,我要问的是,我想做的事情是否可能,如果可以,怎么做?

由于二进制可以转换为 ASCII 或 BASE-64,反之亦然,因此转换为数字并返回也应该可以工作。毕竟,Base64 基本上是基于 64 的数字系统,而十进制数字是基于 10 的系统,而二进制是基于 2 的系统。

任何意见,将不胜感激。

0 投票
7 回答
2393 浏览

python - python 十六进制到十进制使用for循环

即使在反转范​​围顺序并重新导入之后,我仍然得到相同的结果。

0 投票
1 回答
199 浏览

delphi - 使用递归函数进行数字系统转换 - 返回值错误

我必须制作一个程序,我必须将十进制系统中的数字转换为另一个数字(以 2 为底到 9),就像我的第一个问题一样。

但这一次我必须使用递归函数来实现。所以我来了:

它需要 2 个整数变量,“n”是十进制数,“b”是基数,并返回一个带有转换后数字的字符串。在按钮过程中,我在 TMemo 中显示数字

我遇到的问题是:使用函数的方式以相反的顺序给出数字(例如,基数 9 中的 301 是 364,但它显示为 463)。但是,如果我在 if 语句之后使用 ReverseString 函数,那么它会以不同的顺序显示数字(在示例中,数字现在是 634)。

但是,如果我在 memo1.Lines.Add (函数外部)应用 ReverseString 函数,那么它会显示正确的转换。

我想知道如何让它通过函数本身返回正确的数字顺序。

该程序编译它没有任何错误。

再次感谢您的阅读。

利奥AM

0 投票
1 回答
739 浏览

c# - 从十六进制、二进制、八进制转换文件

我正处于编辑器项目的设计阶段。我总是以二进制格式存储文件。但是要求是,用户必须能够单击“显示格式”按钮,并且文件内容的格式应从二进制更改为十六进制、十进制,反之亦然。做这个的最好方式是什么?我的文件真的很大。

0 投票
0 回答
105 浏览

javascript - JavaScript - 从 it-IT 的约定 - 意大利(意大利)数字系统到 en-US - 英语(美国)数字系统

我必须通过 JavaScript 将意大利数字系统转换为英文数字系统,并且我在下面编写了代码来实现这一点。

测试用例 :

此代码在某些情况下运行良好,对于失败的情况,我也可以再设置一个if条件并更改它,但是我觉得我所做的一切都不是通用和最佳的方法。

任何人都可以帮助给出一些想法,我该如何编写一些通用代码,这些代码将在每个测试用例中通过。

提前致谢。

0 投票
3 回答
2824 浏览

c++ - How to define a new number system in C++

Essentially what I'm attempting to do is create a base 62 number system in C++ (an alphanumeric number system -- one that includes a-z, A-Z, and 0-9). How would something like this be accomplished? I tried using a char array like this:

const char alphaNum[62] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', ' y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };

however writing functions to use that array and try to count takes way too much code to be practical (for 0 to 61, sure, just select it from the array. The problem arises when you try to do multiple-digit numbers, i.e. 00). It would be much simpler to just say foobar++;. Does anyone have a way to define number systems, or at least a way for me to make it so that I don't have to write a case for every time it reaches Z?

EDIT: it should have been const char, dunno why VS decided it would be fun not to copy some of it.

0 投票
1 回答
1173 浏览

binary - 减去负 2 的补码

我有两个 2 的补码有符号二进制数并想将它们相减(假设是 8 位减法器)

1001 0110

1000 0001

找出差异的操作是什么以及为什么/为什么不存在溢出

0 投票
2 回答
437 浏览

binary - 使用 3 位系统 0,1,2 进行二进制转换

假设系统是由只有 3 个数字的外星生物进化而来的,他们使用数字 0,1,2 和 (2>1>0) ,如何用这个来表示 222 的二进制等价物?

我计算它是, 22020但书回答它 11010 。这是怎么回事。我不应该使用与从十进制到二进制相同的方法进行二进制转换,除了在这里使用“3”吗?