问题标签 [int64]
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.
c++ - 用于 Windows 和 Linux 的 C++ 中 64 位整数的跨平台定义
我正在尝试用 C++ 为 Windows(MinGW)和 Linux(g++)编写跨平台代码。我习惯在 Linux 中将 64 位整数定义为“long”,但是当我转到 MinGW 时,sizeof(long) 返回 4 个字节。然后我发现我可以在 MinGW 中使用“long long”或“__INT64”来定义 64 位整数。我有两个问题:
1.-为 Windows 和 Linux 定义 64 位整数的最便携方式是什么?我目前正在使用#ifdef,但我不知道这是否是最好的方法:
2.-我应该在 MinGW 中使用“long long”还是“__INT64”?为什么?
.net - .NET 方法用 Long 类型限定符解析字符串
我从带有长类型限定符的第 3 方软件中得到一个字符串,例如“1L”。我想将其解析为 Int64,但 Int64.TryParse 无法将其识别为 Int64。有没有一种 .NET 方法可以安全地做到这一点?我想避免解析自己...
谢谢你的帮助!
c++ - Setting all bits in int64_t
From following code I expect to set all bits in x to 1, but somehow only first 32 bits are set:
Note: printing x after each line results in 4294967295 (32 lower bits set to 1).
Also, tried using numeric_limits<int64_t>::min()
with no success.
My question is how to set all bits in x?
Using RHEL5.5.
Thx
math - 如何计算两个 int64 数乘以另一个 int64 数的结果?
设a、b、c为long long (int64)数,如何计算(a*b)%c?这里的问题是你不能乘以 (a%c)*(b%c) 因为它不适合 int64 变量。那么,它可以做什么呢?
以防万一它有帮助,我正在使用 C++。
printing - 如何使用 fmt 在 Go 中打印出常量 uint64?
我试过:
fmt.Printf("%d", math.MaxUint64)
但我收到以下错误消息:
常量 18446744073709551615 溢出 int
我怎样才能解决这个问题?谢谢!
c++ - __int64 的奇怪列表输出
__int64
我对和有问题%I64u
。或者我的公式可能有问题。我试图模仿下面的输出。但是在某些订单项中发生了一件奇怪的事情。我不明白发生了什么,因为其他人打印得很好。
注意:这些列表的主要来源来自二进制原始数据。所以我从十六进制中获取它并尝试将其转换为__int64
. 我的列表由120
行项目组成,这些行项目输出良好,73
并且从行中失败74
,预期值为2276812558
并显示18446744071691396878
。从排队74
到排队120
的结果是intermittent
。其他没问题,其他线路失败。
有人帮忙吗??
资源:
这是我的代码:
.输出产生
c++ - what is the performance impact of using int64_t instead of int32_t on 32-bit systems?
Our C++ library currently uses time_t for storing time values. I'm beginning to need sub-second precision in some places, so a larger data type will be necessary there anyway. Also, it might be useful to get around the Year-2038 problem in some places. So I'm thinking about completely switching to a single Time class with an underlying int64_t value, to replace the time_t value in all places.
Now I'm wondering about the performance impact of such a change when running this code on a 32-bit operating system or 32-bit CPU. IIUC the compiler will generate code to perform 64-bit arithmetic using 32-bit registers. But if this is too slow, I might have to use a more differentiated way for dealing with time values, which might make the software more difficult to maintain.
What I'm interested in:
- which factors influence performance of these operations? Probably the compiler and compiler version; but does the operating system or the CPU make/model influence this as well? Will a normal 32-bit system use the 64-bit registers of modern CPUs?
- which operations will be especially slow when emulated on 32-bit? Or which will have nearly no slowdown?
- are there any existing benchmark results for using int64_t/uint64_t on 32-bit systems?
- does anyone have own experience about this performance impact?
I'm mostly interested in g++ 4.1 and 4.4 on Linux 2.6 (RHEL5, RHEL6) on Intel Core 2 systems; but it would also be nice to know about the situation for other systems (like Sparc Solaris + Solaris CC, Windows + MSVC).
c - 如何将字符串转换为 int64_t?
如何将程序参数从 转换argv
为int64_t
?atoi()
仅适用于 32 位整数。
c - How to divide int64_t to two int32_t and send it over the network?
I want to send two int64_t
over UDP. To do this I store them in a four-element array, where:
- [0] - lower 32 its of the first
int64_t
- [1] - higher 32 bits of the first
int64_t
- [2] - lower 32 bits of the second
int64_t
- [3] - higher 32 bits if the second
int64_t
My code for sending:
My code for combining int32_t
back to int64_t
after receiving data
via UDP:
The first number (from
) is always correct. However, what I get from the second printf
is incorrect. What's more, it seems to be dependent on the first number. Example:
Sending:
from
= 125,to
= 20.
Received:
from
= 125,to
= 125.
Sending:
from
= 1252,to
= 20.
Received:
from
= 1252,to
= 1268.
What am I doing wrong? Is it the problem of conversion or sending over the network?
c++ - size_t 和 __w64、time_t 和 __int64 是如何工作的?
我不是 C 或 C++ 方面的老手。我不知道如何time_t
定义和设计。几个帖子,如:
但这些帖子只说明什么是time_t
或size_t
。它没有明确说明 time_t 或 size_t 是如何以及在何处定义和声明的。
我正在使用WIN8 VS2012 Express C++。我搜索了库,发现它size_t
是在crtdefs.h
而不是cstddef
.
- 为什么需要像
size_t
,之类的类型time_t
?我们可以让sizeof
只是返回unsigned int
。 - 为什么 C++ 库没有定义
size_t
? - 我可以说 size_t不是C/C++ 内置类型吗?
- 我永远不需要在我的程序中包含相应的头文件来使用
size_t
或time_t
(也许它们是在std
命名空间中定义的)。
我在库中再次搜索,发现size_t
定义为typedef _W64 unsigned int size_t
,_W64
定义为__w64
。在这里,我无法更多地搜索__w64
定义或声明的位置。
- 什么是
__w64
类型?C++11/C99 标准中没有说明。
同样,当我搜索 时time_t
,我发现__int6
. 却不知从何__int64
而来。