casting

Cannot SUM(TO_NUMBER(varchar2 field)) :ORA 01722 [ORACLE]

為{幸葍}努か 提交于 2019-12-13 22:01:31
问题 I have myfield as varchar2 type and I try to sum this field by using sum(to_number(myfield)) but the result is ORA-01722 invalid number. before this error occured I used SUM(TO_NUMBER(REGEXP_REPLACE(BIKOU,'[[:alpha:]]', ''))) and it works but last week I put some decimal value in myfield so this code not work anymore. Here is my example of data in myfield 10,12,13.5,NULL 回答1: If you're getting that error from a string like 13.5 then your session's NLS_NUMERIC_CHARACTERS seems to be set to use

Explicit casting on objects with interface. What's the use of parentheses

梦想与她 提交于 2019-12-13 21:23:30
问题 I have found a similar question, but it didn't really concern the interface issue - Issue about casting object brackets public class Speak { /* Line 1 */ public static void main(String[] args) { /* Line 2 */ Speak speakIT = new Tell(); /* Line 3 */ Tell tellIt = new Tell(); /* Line 4 */ speakIT.tellItLikeItIs(); /* Line 5 */ (Truth)speakIt.tellItLikeItIs(); /*Line 6 */ ((Truth)speakIt).tellItLikeItIs(); /* Line 7 */ tellIt.tellItLikeItIs(); /* Line 8 */ (Truth)tellIt.tellItLikeItIs(); /* Line

LPCTSTR typecast for use with GetFileAttributes

十年热恋 提交于 2019-12-13 21:08:06
问题 I´m trying to build a method to see if a file exists. the method in it´s current isn´t complete form. i´m trying to figur out whyy it doesn´t behave as code. BOOL FileExists(LPCTSTR szPath) { //MessageBox(NULL,szPath,L"File Error",MB_OK); DWORD dwAttrib = GetFileAttributes(szPath); switch(dwAttrib) { case FILE_ATTRIBUTE_DIRECTORY: MessageBox(NULL,L"FILE_ATTRIBUTE_DIRECTORY",L"File Error",MB_OK); break; case FILE_ATTRIBUTE_ARCHIVE: MessageBox(NULL,L"FILE_ATTRIBUTE_ARCHIVE",L"File Error",MB_OK)

Java: How to test if an input is a double or an int

五迷三道 提交于 2019-12-13 21:03:48
问题 I have a do while loop. Checking x is between two values. Now im supposed to be taking in an int value, but if the user types a double im getting exceptions. How do I incorparate a check in the same if statement so that if the user types a double it would print something like "x must be an int between 10 and 150:" do { x = sc.nextInt(); if ( x < 10 || x > 150 ) { System.out.print("x between 10 and 150: "); } else { break; } 回答1: You can just catch the exception and handle it, using a while

C# (CS0039) How to define conversion to a custom class from a string, with the `as` operator?

非 Y 不嫁゛ 提交于 2019-12-13 20:35:40
问题 Is is possible to define (perhaps) an operator for a class which could enable using 'as' conversion? The point is: class C { string a; string b; public C what_here(string s) { a = s.Substring(0, 2); b = s.Substring(3); } } The class' use: ("something" as C).a; This gives: Error CS0039: Cannot convert type 'string' to 'C' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion P.S. the true class C is much bigger, the point is just how

Is this an unavoidable signed and unsigned integer comparison?

廉价感情. 提交于 2019-12-13 20:04:52
问题 Probably not, but I can't think of a good solution. I'm no expert in C++ yet. Recently I've converted a lot of int s to unsigned int s in a project. Basically everything that should never be negative is made unsigned. This removed a lot of these warnings by MinGW: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] I love it. It makes the program more robust and the code more descriptive. However, there is one place where they still occur. It looks like this:

What does reinterpret_cast do binary-wise?

可紊 提交于 2019-12-13 19:50:40
问题 I'm writing a logger in C++, and I've come to the part where I'd like to take a log record and write in to a file. I have created a LogRecord struct, and would like to serialize it and write it to a file in binary mode. I have read some posts about serialization in C++, and one of the answers included this following snippet: reinterpret_cast<char*>(&logRec) I've tried reading about reinterpret_cast and what it does, but I couldn't fully understand what's really happening in the background.

Cast string with comma to float with dot

喜你入骨 提交于 2019-12-13 19:50:27
问题 When I try to cast $value = floatval('14,5833'); to a float type I expect a value with dot like 14.5833 but it returns me 14,5833 . How should I do this ? I wouldn't like to use any string replace functions. 回答1: You have two options: Set locale to something that uses a dot instead of a coma. E.g. setLocale(LC_ALL, 'fr_BE.UTF-8'); Keep using comma internally, and when you want to output that number, use number_format 回答2: An example was helpful for me: <?php setlocale(LC_NUMERIC, 'en_US');

How can I make an array that holds types?

爱⌒轻易说出口 提交于 2019-12-13 19:32:10
问题 I am trying to create an array that holds the class of the custom collectionView cell I would like to deque. Below I have provided an example of how I would like to use this array. cellType is a variable holding the class I would like to deque and cellClass is an array holding different classes. I have seen similar questions to this but all the answers seem to suggest using the an instance of the class such as className.self. Is it possible to create an array like this. Thank You. func

Casting templated class to more general specialization

喜夏-厌秋 提交于 2019-12-13 18:37:52
问题 I have a templated class with the template argument the number of dimensions of some datapoints the class shall save. This class has a specialized version MyClass<-1> that allows for dimensions not known at compile time. How can I cast a specific class (say MyClass<2> ) to this more general form? To be a bit more concrete, here is some artificial example that shows the situation. (I use the Eigen library, but I suppose for the general principle this should not matter) using namespace Eigen;