comparison

How do I efficiently do signed comparisons on the 8080?

家住魔仙堡 提交于 2019-12-19 03:51:10
问题 I want to compare two 16-bit numbers and branch on the result: the equivalent of if (a<b) goto negative . I'm using an Intel 8080. The Z80 has a signed arithmetic overflow flag which can be used for this with some degree of effort. The standard code is: ld de, _left ld hl, _right ld a, e sub a, l ld a, d sbc a, h jp po, $+5 ; branch on overflow flag not set xor a, 0x80 ; flip sign bit jm negative ; actually do the test But the 8080 isn't a strict subset of the Z80, and the code above won't

Does .Value = .Value act similar to Evaluate() function in VBA?

﹥>﹥吖頭↗ 提交于 2019-12-19 03:18:22
问题 Consider the following snippet. It writes the same formula to two cells A1 and A2 Sub Main() With Range("A1") .Formula = "=1+1" End With With Range("A2") .Formula = "=1+1" .Value = .Value End With End Sub The second with block uses .Value = .Value which calculates/executes the formula therefore the formula disappears from the formula bar. Refer to hiding formulas from formula bar for a supportive reference. Now, add another with block With Range("A3") .Formula = "=1+1" End With Range("A4") =

compare two datetime values from SQL Server with c#

时光怂恿深爱的人放手 提交于 2019-12-19 03:13:33
问题 i want to know how compare two datetime values one who is retreived from sql database and the other is the current one with c# 回答1: Beware when comparing DateTimes generated within C#. The DateTime struct in C# has more precision than the datetime 1 type in SQL Server. So if you generate a DateTime in C# (say from DateTime.Now ), store it in the database, and retrieve it back, it will most likely be different. For instance, the following code: using(SqlConnection conn = new SqlConnection(

Float comparison (equality) in CoreGraphics

一笑奈何 提交于 2019-12-19 03:01:05
问题 Apple CoreGraphics.framework , CGGeometry.h : CG_INLINE bool __CGSizeEqualToSize(CGSize size1, CGSize size2) { return size1.width == size2.width && size1.height == size2.height; } #define CGSizeEqualToSize __CGSizeEqualToSize Why do they (Apple) compare floats with == ? I can't believe this is a mistake. So can you explain me? (I've expected something like fabs(size1.width - size2.width) < 0.001 ). 回答1: Floating point comparisons are native width on all OSX and iOS architectures. For float ,

Python: determining whether any item in sequence is equal to any other

冷暖自知 提交于 2019-12-18 21:51:12
问题 I'd like to compare multiple objects and return True only if all objects are not equal among themselves. I tried using the code below, but it doesn't work. If obj1 and obj3 are equal and obj2 and obj3 are not equal, the result is True . obj1 != obj2 != obj3 I have more than 3 objects to compare. Using the code below is out of question: all([obj1 != obj2, obj1 != obj3, obj2 != obj3]) 回答1: @Michael Hoffman's answer is good if the objects are all hashable. If not, you can use itertools

Wrong compiler warning when comparing struct to null

喜你入骨 提交于 2019-12-18 19:27:29
问题 Consider the following code: DateTime t = DateTime.Today; bool isGreater = t > null; With Visual Studio 2010 (C# 4, .NET 4.0), I get the following warning: warning CS0458: The result of the expression is always 'null' of type 'bool?' This is incorrect; the result is always false (of type bool ): Now, the struct DateTime overloads the > (greater than) operator. Any non-nullable struct (like DateTime) is implicitly convertible to the corresponding Nullable<> type. The above expression is

Char Comparison in C

元气小坏坏 提交于 2019-12-18 18:59:16
问题 I'm trying to compare two chars to see if one is greater than the other. To see if they were equal, I used strcmp . Is there anything similar to strcmp that I can use? 回答1: A char variable is actually an 8-bit integral value. It will have values from 0 to 255 . These are ASCII codes. 0 stands for the C-null character, and 255 stands for an empty symbol. So, when you write the following assignment: char a = 'a'; It is the same thing as: char a = 97; So, you can compare two char variables using

Char Comparison in C

夙愿已清 提交于 2019-12-18 18:59:07
问题 I'm trying to compare two chars to see if one is greater than the other. To see if they were equal, I used strcmp . Is there anything similar to strcmp that I can use? 回答1: A char variable is actually an 8-bit integral value. It will have values from 0 to 255 . These are ASCII codes. 0 stands for the C-null character, and 255 stands for an empty symbol. So, when you write the following assignment: char a = 'a'; It is the same thing as: char a = 97; So, you can compare two char variables using

Why are chained operator expressions slower than their expanded equivalent?

℡╲_俬逩灬. 提交于 2019-12-18 14:48:17
问题 In python, it is possible to chain operators in this manner: a op b op c Which is evaluated to a op b and b op c With the only difference being that b is evaluated only once (so, something more like t = eval(b); a op t and t op c ). This is advantageous from the view point that it is very readable and more concise than the equivalent version with explicit conjunction (using and ). However... I've noticed that there is a minor performance difference between chained expressions and the

Compare two spectogram to find the offset where they match algorithm

你离开我真会死。 提交于 2019-12-18 13:39:09
问题 I record a daily 2 minutes radio broadcast from Internet. There's always the same starting and ending jingle. Since the radio broadcast exact time may vary from more or less 6 minutes I have to record around 15 minutes of radio. I wish to identify the exact time where those jingles are in the 15 minutes record, so I can extract the portion of audio I want. I already started a C# application where I decode an MP3 to PCM data and convert the PCM data to a spectrogram based on http://www