Search Results

Search found 4919 results on 197 pages for 'integer'.

Page 17/197 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • simple PHP integer conversion

    - by Ygam
    convert this: $300 to this : 300 can't do it with intval() or (int) typecasting if the non-numerical character is suffixed (300$), both works and returns 300 if it is prefixed it returns 0 the non-numerical character can be anything other than the "$"(i.e. "askldjflksdjflsd") Please help

    Read the article

  • Spring: PropertyPlaceHolderConfigurer to set values for non-string/integer properties

    - by babyangel86
    Hi, All the examples I have seen where the PropertyPlaceHolderConfigurer is used seem to be setting simple values like Strings and ints. How do you use the PPC to set the values of classes. E.g. If i had a class signature Source(String name, DistributionSample batch, DistributionSample delay) How would I go about setting the batch and delay properties. There is also a small catch. DistributionSample is an abstract class. On the bright side, The class that is using the propertyPlaceHolder knows the beanName of the "Solid" class that needs to be instantiated. Any help would be much appreciated.

    Read the article

  • Should i really use integer primary IDs?

    - by arthurprs
    For example, i always generate an auto-increment field for the users table, but i also specifies an UNIQUE index on their usernames. There is situations that i first need to get the userId for a given username and then execute the desired query. Or use a JOIN in the desired query. It's 2 trips to the database or a JOIN vs. a varchar index The above is just an example There is a real performance benefit on INT over small VARCHAR indexes? Thanks in advance!

    Read the article

  • How to provide a date variable an interval that consists of an integer variable in Postgresql

    - by Lucius Rutilius Lupus
    I am trying to extract an amount of years from a specific date for this the correct syntax is <date> - interval '5 years'; But I dont want to extract a specific amount of years but a variable, which user will provide as a parameter. I have tried the following the variable name is years : date+interval '% years',years; I am getting an error and it doesn't let me do it that way. What would be the right way to do it.

    Read the article

  • To have an Integer pointing to 3 ordered lists in Java

    - by Masi
    Which datastructure would you use in the place of X to have efficient merges, sorts and additions as described below? #1 Possible solution: one HashMap to X -datastructure Having a HashMap pointing from fileID to some datastructure linking word, wordCount and wordID may be a good solution. However, I have not found a way to implement it. I am not allowed to use Postgres or any similar tool to keep my data neutralized. I want to have efficient merges, sorts and additions according to fileID, wordID or wordCount for the type below. I have the type Words which has th field fileID that points to a list of words and to relating pieces of information: The Type class Words =================================== fileID: int [list of words] : ArrayList [list of wordCounts] : ArrayList [list of wordIDs] : ArrayList Example of the data in fileID word wordCount wordID instance1 of words 1 He 123 1111 1 llo 321 2 instance2 of words 2 Van 213 666 2 cou 777 932 Example of needed merge fileID wordID fileID wordID 1 2 1 3 wordID=2 2 2 ========> 1 2 2 3 2 2 I cannot see any usage of set-operations such as intersections here because order is needed. Having about three HashMaps makes sorting difficult: from word to wordID in a given fileID from wordID to fileID from wordID to wordCount in a given fileID

    Read the article

  • Nullable Integer ? (working with linq)

    - by nCdy
    I've got exception about convert NULL to Int32. I've got a table from database with nullable tinyint [Column(Storage="_StatType", DbType="tinyint NULL")] public StatType : int { get { _StatType; } } (to get C# code just replace variable's type) and after making linq select def StartLinq = linq <#from lpi in _CfgListParIzm where lpi.ID_ListParIzm==drr1 select (lpi.StatType) #> ; StartLinq.ToArray()[0] can't be readed if that is null :-/ mutable STT : int = 0; try { _=int.TryParse(StartLinq.ToArray()[0].ToString(), out STT); } catch { | _ is Exception => () /* I don't care*/ } upper code is very poor trick :( I wont use it.

    Read the article

  • Converting an integer to a boxed enum type only known at runtime

    - by Marc Gravell
    Imagine we have an enum: enum Foo { A=1,B=2,C=3 } If the type is known at compile-time, a direct cast can be used to change between the enum-type and the underlying type (usually int): static int GetValue() { return 2; } ... Foo foo = (Foo)GetValue(); // becomes Foo.B And boxing this gives a box of type Foo: object o1 = foo; Console.WriteLine(o1.GetType().Name); // writes Foo (and indeed, you can box as Foo and unbox as int, or box as int and unbox as Foo quite happily) However (the problem); if the enum type is only known at runtime things are... trickier. It is obviously trivial to box it as an int - but can I box it as Foo? (Ideally without using generics and MakeGenericMethod, which would be ugly). Convert.ChangeType throws an exception. ToString and Enum.Parse works, but is horribly inefficient. I could look at the defined values (Enum.GetValues or Type.GetFields), but that is very hard for [Flags], and even without would require getting back to the underlying-type first (which isn't as hard, thankfully). But; is there a more direct to get from a value of the correct underlying-type to a box of the enum-type, where the type is only known at runtime?

    Read the article

  • fwrite write an integer

    - by user149100
    I'm trying to write a word to a file using this function: extern void write_int(FILE * out, int num) { fwrite(&num,sizeof(int),1, out); if(ferror(out)){ perror(__func__); exit(EXIT_FAILURE); } } But I get a segmentation fault whenever it tries to run the fwrite. I looked at the man page for fwrite(3) and I feel like I used it correctly, is there something I'm missing?

    Read the article

  • Outputing value of TrueClass / FalseClass to integer or string/

    - by Nick Gorbikoff
    Hello. I'm trying to figure out if there is an easy way to do the following short of adding to_i method to TrueClass/FalseClass. Here is a dilemma: I have a boolean field in my rails app - that is obviously stored as Tinyint in mysql. However - I need to generate xml based of the data in mysql and send it to customer - there SOAP service requires the field in question to have 0 or 1 as the value of this field. So at the time of the xml generation I need to convert my False to 0 and my True to 1 ( which is how they are stored in the DB). Since True & False lack to_i method I could write some if statement that generate either 1 or 0 depending on true/false state. However I have about 10 of these indicators and creating and if/else for each is not very DRY. So what you recommend I do? Or I could add a to_i method to the True / False class. But I'm not sure where should I scope it in my rails app? Just inside this particular model or somewhere else?

    Read the article

  • Date arithmetic using integer values

    - by Dave Jarvis
    Problem String concatenation is slowing down a query: date(extract(YEAR FROM m.taken)||'-1-1') d1, date(extract(YEAR FROM m.taken)||'-1-31') d2 This is realized in code as part of a string, which follows (where the p_ variables are integers): date(extract(YEAR FROM m.taken)||''-'||p_month1||'-'||p_day1||''') d1, date(extract(YEAR FROM m.taken)||''-'||p_month2||'-'||p_day2||''') d2 This part of the query runs in 3.2 seconds with the dates, and 1.5 seconds without, leading me to believe there is ample room for improvement. Question What is a better way to create the date (presumably without concatenation)? Many thanks!

    Read the article

  • Converting TrueClass / FalseClass to integer.

    - by Nick Gorbikoff
    Hello. I'm trying to figure out if there is an easy way to do the following short of adding to_i method to TrueClass/FalseClass. Here is a dilemma: I have a boolean field in my rails app - that is obviously stored as Tinyint in mysql. However - I need to generate xml based of the data in mysql and send it to customer - there SOAP service requires the field in question to have 0 or 1 as the value of this field. So at the time of the xml generation I need to convert my False to 0 and my True to 1 ( which is how they are stored in the DB). Since True & False lack to_i method I could write some if statement that generate either 1 or 0 depending on true/false state. However I have about 10 of these indicators and creating and if/else for each is not very DRY. So what you recommend I do? Or I could add a to_i method to the True / False class. But I'm not sure where should I scope it in my rails app? Just inside this particular model or somewhere else?

    Read the article

  • Find a missing 32bit integer among a unsorted array containing at most 4 billion ints

    - by pierr
    Hi, This is the problem described in Programming pearls. I can not understand binary search method descrbied by the author. Can any one helps to elaborate? Thanks. EDIT: I can understand binary search in general. I just can not understand how to apply binary search in this special case. How to decide the missing number is in or not in some range so that we can choose another. English is not my native language, that is one reason I can not understand the author well. So, use plain english please:) EDIT: Thank you all for your great answer and comments ! The most important lesson I leant from solving this question is Binary search applies not only on sorted array!

    Read the article

  • Sphinx non-fulltext, integer only search

    - by James
    Hello guys, I've got a few tables that literally only hold integers, no "words" and for some reason Sphinx is unable to hold this data in it's library. Just returns "0 bytes" errors for these indexes. Is it possible to do this? If so, how? Below is an example from my Sphinx.conf for one that fails. source track { type = mysql sql_host = host sql_user = user sql_pass = pass sql_db = db sql_port = port sql_query = SELECT id, user, time FROM track; sql_attr_uint = user sql_attr_uint = time sql_query_info = SELECT * FROM track WHERE id=$id } index track { source = track path = /var/lib/sphinx/track docinfo = extern charset_type = utf-8 min_prefix_len = 1 enable_star = 1 }

    Read the article

  • Angularjs: addition of integers even after I parse the variable as integer

    - by Shiv Kumar
    I really have a weird problem in adding two numbers. Here is my code, in the first controller everything is working fine, but in the second controller instead of 0 if I add 10, the output is completely weird Here is html code <div ng-app=""> <div ng-controller="Controller1"> <br/>**** Controller-1 <br/>Add 0 : {{update1(0)}} <br/>Add 10 : {{update1(10)}} <br/>Add 50 : {{update1(50)}} <br/>Add -60 : {{update1(-60)}}</div> <div ng-controller="Controller2"> <br/>**** Controller-2 <br/>Add 10 : {{update2(10)}} <br/>Add 10 : {{update2(10)}} <br/>Add 50 : {{update2(50)}} <br/>Add -60 : {{update2(-60)}}</div> </div> Here is my javascript function Controller1($scope) { var x = 0; $scope.update1 = function (smValue) { x += parseInt(smValue); return x; } } function Controller2($scope) { var y = 0; $scope.update2 = function (smValue) { y += parseInt(smValue); return y; } } and here is the output **** Controller-1 Add 0 : 0 Add 10 : 10 Add 50 : 60 Add -60 : 0 **** Controller-2 Add 0 : 110 Add 10 : 120 Add 50 : 170 Add -60 : 110 here is the link to try: http://jsfiddle.net/6VqqN/ can anyone please explain me why it is behaving like that. Even if I add a 3or4 digit number, output is completely different then what I expected.

    Read the article

  • Python: Convert a string to an integer

    - by Adam Nelson
    Does anybody have a quickie for converting an unsafe string to an int? The string typically comes back as: '234\r\n' or something like that. In this case I want 234. If '-1\r\n', I want -1. I never want the method to fail but I don't want to go so far as try, except, pass just to hide errors either (in case something extreme happens).

    Read the article

  • long integer problem

    - by hopefulLLl
    hello friends,, m a beginner at c language.. m using turbo c ++ compiler 16 bit. nw the max answer obtained by me is aaround 32000.. nw if i want a number larger that that then i use long int.. if i execute the following programme.. #include <stdio.h> void main() { long int x; x=40000; printf("%d", x); } then i get error that constant value is long in function main().. kindly tell me how to get an answer more that 32000 by getting rid of this error! thnx..

    Read the article

  • Format string, integer with leading zeros

    - by ghiboz
    Hi all! I Use this code: NSString* strName = [NSString stringWithFormat:@"img_00%d.jpg", pp]; and works fine, but if pp took the value of 10 for example I wish have img_010.jpg as result, and not img_0010.jpg... how can I format the string?? thanks

    Read the article

  • Getting sign of an integer in Assembly

    - by Sagekilla
    Hi all, I'm writing some assembly for a project using MASM (32-bit), and I was wondering what would be the easiest way to do this: int delta = A - B; int value = floor((delta + sign(delta)) / 2); Which is basically the following mapping: For 1 < A < 9, and B = 5: A = [1, 2] -> -2 A = [3, 4] -> -1 A = [5] -> 0 A = [6, 7] -> +1 A = [8, 9] -> +1 Any help is much appreciated!

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >