primitive

VisualVM OQL: how to search for primitive float values rather than actual Float instances?

随声附和 提交于 2019-12-23 01:25:17
问题 I am wondering how one can search for all primitive float values that match a certain number. When doing something like: select n from java.lang.Float n where n.value == 1.00 Only the Float class instances are being found. The application I am exploring is using different wrappers than just Float (eg. Vectors) that use primitive float values as fields for which I need to search. How would I accomplish this? The following returns a "float is not found error": select n from float n where n

Core Data Primitive Accessors

混江龙づ霸主 提交于 2019-12-22 07:09:07
问题 I'm a little confused by whether Core Data generates primitive accessors for NSManagedObject subclasses in the form setPrimitiveAttributeName:, as compared to the form setPrimitiveValue: forKey:, which it seems to do consistently. The source of my confusion is that I have used the modeling tool (XCode 4) to generate NSManagedSubclasses for two of my entities, which, as far as I can tell, share the same metadata settings, yet one subclass recognizes the setPrimitiveAttributeName form, whereas

C# - Fastest Way To Sort Array Of Primitives And Track Their Indices

那年仲夏 提交于 2019-12-22 05:33:21
问题 I need a float[] to be sorted. And I need to know where the old indices are in new array. That's why I can't use Array.Sort(); or whatever. So I would like to write a function that sorts the array for me and remembers from what index it took each value: float[] input = new float[] {1.5, 2, 0, 0.4, -1, 96, -56, 8, -45}; // sort float[] output; // {-56, -45, -1, 0, 0.4, 1.5, 2, 8, 96}; int[] indices; // {6, 8, 4, 2, 3, 0, 1, 7, 5}; Size of arrays would be around 500. How should I approach this

Assigning result of an expression to a primitive

混江龙づ霸主 提交于 2019-12-21 21:27:26
问题 K.Sierra in her book "SCJP Study Guide" mentions "We know that a literal integer is always an int, but more importantly, the result of an expression involving anything int-sized or smaller is always an int." I've started experimenting and I'm a little bit confused with the below results: byte a = 1; // correct byte b = 1 + a; // incorrect (needs explicit casting) byte c = 1 + 1; // correct (I expected it to be incorrect) Could anyone explain to me why the last example does not require casting

Should I really use static_cast every single time I want to convert between primitive types?

痞子三分冷 提交于 2019-12-21 09:16:59
问题 What makes this long l = 1; char c = static_cast<char>(l); float f = 1.0f; int i = static_cast<int>(f); better than this long l = 1; char c = (char)l; float f = 1.0f; int i = (int)f; when casting one primitive data type to another? I've got much of legacy code that uses the second style for type casting in similar situations, so this is also a question about should I or may I not perform full-scale revision of that code. 回答1: Future-proofing. Let's say in the future I do this: float blah = 1

Should I really use static_cast every single time I want to convert between primitive types?

不羁的心 提交于 2019-12-21 09:16:22
问题 What makes this long l = 1; char c = static_cast<char>(l); float f = 1.0f; int i = static_cast<int>(f); better than this long l = 1; char c = (char)l; float f = 1.0f; int i = (int)f; when casting one primitive data type to another? I've got much of legacy code that uses the second style for type casting in similar situations, so this is also a question about should I or may I not perform full-scale revision of that code. 回答1: Future-proofing. Let's say in the future I do this: float blah = 1

How do I make a class assignable to primitives? Or, how do I make a scalar class?

天涯浪子 提交于 2019-12-20 02:11:10
问题 I was wondering if it's possible to make my class Time { public: Time(); explicit Time( const double& d); Time& operator=( const Time& time); Time& operator=( const double& d); }; assignable to the primitive double? I'm using Time as an IV a lot and need to do a lot of scalar operations on it, so it needs to "mingle" with DV's which are usually ordinary doubles. Adding a second assignment operator did the trick the other way around. A lot of operations still aren't possible with just this

Is there a way to specialize a template to target primitives? [duplicate]

我的梦境 提交于 2019-12-19 09:57:53
问题 This question already has answers here : Identifying primitive types in templates (8 answers) Closed last year . In specializing a class template, I would like to have one specialization target full-blown classes (complete with constructor, destructor, etc.) and one specialization target primitives ( int , float , etc.). The only partial specialization I've seen is with targeting pointer types (via T* ). Is there a way to do this? 回答1: You can used C++11 type_traits. Here is something to get

Behind the scenes, what's happening with decimal value type in C#/.NET?

我怕爱的太早我们不能终老 提交于 2019-12-18 12:54:06
问题 How is the decimal type implemented? Update It's a 128-bit value type (16 bytes) 1 sign bit 96 bits (12 bytes) for the mantissa 8 bits for the exponent remaining bits (23 of them!) set to 0 Thanks! I'm gonna stick with using a 64-bit long with my own implied scale. 回答1: Decimal Floating Point article on Wikipedia with specific link to this article about System.Decimal. A decimal is stored in 128 bits, even though only 102 are strictly necessary. It is convenient to consider the decimal as

Why can I assign an integer literal to a short type variable but not to a short type method parameter?

放肆的年华 提交于 2019-12-18 12:26:08
问题 Why can I do this: short a = 5; But not this: void setNum(short a); setNum(5); It throws: Possible lossy conversion from int to short I understand that 5 is an integer literal and you have to cast it. I also understand that if the value is not a constant then is obvious that it needs to throw that error because maybe the value reaches the limit of a short type. But why if the compiler knows I'm passing a constant that a short can hold (as in the assignment) it doesn't let it compile? I mean,