系统内存不足吗?(Is the system memory-less?)
我有一个关于数字信号处理的问题。 是
h(n)= (2 n+5)u(n)
内存少? 我认为因为
u(n)
,系统是无记忆的。 我对吗?I got a Question on digital signal processing. Is
h(n)= (2 n+5)u(n)
memory-less? I think that the because of
u(n)
, the system is memory-less. Am I right?
原文:https://stackoverflow.com/questions/29291749
更新时间:2024-03-11 21:03
最满意答案
移位并添加:
exModel = 0x2; model = 0xE; output = (exModel << 4) + model;
由于在上面的评论中提到过,你也可以使用联合,但我不会推荐它 - 它使代码非常不便携(并且我认为违反了严格的别名规则):
union myUnion { unsigned char output; struct { unsigned char model : 4; // the order of these two fields unsigned char exModel : 4; // is system dependent }; }; union myUnion u; u.exModel = 0x2; u.model = 0xE; output = u.output;
Shift and add:
exModel = 0x2; model = 0xE; output = (exModel << 4) + model;
Since it was mentioned in the comment above, you could also use a union, but I wouldn't recommend it - it makes the code pretty nonportable (and I think violates strict aliasing rules):
union myUnion { unsigned char output; struct { unsigned char model : 4; // the order of these two fields unsigned char exModel : 4; // is system dependent }; }; union myUnion u; u.exModel = 0x2; u.model = 0xE; output = u.output;
相关问答
更多-
我认为ImageMagick(或GraphicsMagick)可以使用-depth选项执行此操作。 这里有一个讨论: http : //www.imagemagick.org/discourse-server/viewtopic.php?f = 1&t = 15395 更新:我应该补充一点,ImageMagick不是一个PHP库,但是在http://pecl.php.net/package/imagick上有一个PECL包装器(imagick)。 In the end, despite the wonder ...
-
使用无符号整数的div(Using div with unsigned integers)[2023-05-08]
当天, /和%的结果不是由C唯一定义的,而div()是出生的。 现在的商被截断为0。 unsigned数学没有这个问题,所以对udiv()需求较少。 现在许多编译器都可以识别附近的a/b和a%b计算并进行优化,从而减少对div() 。 建议只执行两次计算并让编译器优化它。 [编辑] 细节:在C99之前,分区可能会向0向INT_MIN截断,或者(也许可能最接近 - 我会研究它)。 无论如何, %是划分后的剩余部分。 div()被指定为只执行一个:用截断向0分割。对于C99, div()和/执行将商截断为0的除 ... -
4位ECC算法(4-bit ECC algorithm)[2023-05-22]
你最好的选择可能是Reed Solomon Code 。 以下是对它们如何工作的非常好的解释, 这里有一些实际实现该算法的代码。 它没有评论得很好,抱歉。 一些谷歌行动会更多。 祝你好运。 Your best bet is probably a Reed Solomon Code. Here is a pretty good explanation of how they work, and here is some code that actually implements the algorithm. ... -
64位和32位整数(64-bit and 32-bit integers)[2023-02-03]
如果您确实需要您所说的内容(64位上的32位和64位32位),则需要使用宏。 但是你可能想要的只是使用size_t 。 编辑: size_t保证足够大,可以调整任何对象的大小并索引任何数组。 因此,64位上的32位和64位通常是32位。 所以它可能正是你想要的。 If you really want exactly what you said (32-bit on 32-bit and 64-bit on 64-bit) you'll need to use macros. But what you pro ... -
连接4位整数(Concatenating 4-bit integers)[2022-08-08]
移位并添加: exModel = 0x2; model = 0xE; output = (exModel << 4) + model; 由于在上面的评论中提到过,你也可以使用联合,但我不会推荐它 - 它使代码非常不便携(并且我认为违反了严格的别名规则): union myUnion { unsigned char output; struct { unsigned char model : 4; // the order of these two fields ... -
带符号和无符号符号只是解释位模式的方式,而不是位模式本身。 所以如果只要你的整数在0到255范围内,你可以将它们堵塞成字节并将字节写入文件。 但是,由于Java将字节位模式解释为正在签名,因此在重新读入时必须小心。 例如,假设你有整数253 。 这是(完整的32位格式): 00000000000000000000000011111101 如果你这样做: int i = 253; byte b = (byte) i; 那么b将包含这些位: 11111101 如果你要求Java使用它,Java会声称它是- ...
-
我如何乘以2个32位整数产生一个64位整数?(How do I multiply 2 32-bit integers to produce a 64-bit integer?)[2022-02-12]
#includeuint64_t mul64(uint32_t x, uint32_t y) { return (uint64_t)x*(uint64_t)y; } #include uint64_t mul64(uint32_t x, uint32_t y) { return (uint64_t)x*(uint64_t)y; } -
C#中的4位枚举(4-bit Enum in C#)[2023-08-24]
来自C#规范: 枚举的已批准类型是byte , sbyte , short , ushort , int , uint , long或ulong 。 这些都不是4位类型。 你在C ++方面也有同样的问题。 From the C# spec: The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong. None of these are 4-bit types. You'd have the ... -
您需要使用始终为64位而不是NSUInteger 。 您可以使用uint64_t或unsigned long long 。 您还需要从NSNumber中获取整数值(数组不能存储C类型)。 要做到这一点你需要打电话 uint64_t minID = [Ids.lastObject longLongValue]; 编辑 更改为在示例代码中使用uint64_t,因为它已被正确指出,这更好地显示了您的意图。 You need to use a type that is always 64 bit instead ...
-
QML中的64位整数(64 bit integers in QML)[2023-05-30]
创建自己的从QObject派生的Integer64类,并为其提供所需的功能,例如 class Integer64 : public QObject { Q_OBJECT public: // ... Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged) QString value() const; void setValue(QString value); Q_INV ...