Search Results

Search found 1145 results on 46 pages for 'numeric'.

Page 7/46 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • regex numeric data processing: match a series of numbers greater than X

    - by Mu Mind
    Say I have some data like this: number_stream = [0,0,0,7,8,0,0,2,5,6,10,11,10,13,5,0,1,0,...] I want to process it looking for "bumps" that meet a certain pattern. Imagine I have my own customized regex language for working on numbers, where [[ =5 ]] represents any number = 5. I want to capture this case: ([[ >=5 ]]{3,})[[ <3 ]]{2,} In other words, I want to begin capturing any time I look ahead and see 3 or more values = 5 in a row, and stop capturing any time I look ahead and see 2+ values < 3. So my output should be: >>> stream_processor.process(number_stream) [[5,6,10,11,10,13,5],...] Note that the first 7,8,... is ignored because it's not long enough, and that the capture ends before the 0,1,0.... I'd also like a stream_processor object I can incrementally pass more data into in subsequent process calls, and return captured chunks as they're completed. I've written some code to do it, but it was hideous and state-machiney, and I can't help feeling like I'm missing something obvious. Any ideas to do this cleanly?

    Read the article

  • C++: Checking for non-numeric input and assigning to a double

    - by Brundle
    Here is the code I have at the moment: char ch; int sum = 0; double values[10]; int i = 0; cin >> ch; while (!isalpha(ch)) { values[i] = ch; sum += values[i]; i++; cin >> ch; } What is happening is that if I enter the value 1, that gets assigned to ch as a char. Now ch is assigning it's value to a double and doing an implicit cast. So it is assigning the ASCII value of '1' to values[i]. I want it to just assign 1 to values[i]. Is there a better way to do this? Or is there something that I'm missing?

    Read the article

  • [AJAX Numeric Updown Control] Microsoft JScript runtime error: The number of fractional digits is out of range

    - by Jenson
    If you have using Ajax control toolkits a lot (which I will skip the parts on where to download and how to configure it in Visual Studio 2010), you might have encountered some bugs or limitations of the controls, or rather, some weird behaviours. I would call them weird behaviours though. Recently, I've been working on a Ajax numeric updown control, which i remember clearly it was working fine without problems. In fact, I use 2 numeric updown control this time. So I went on to configure it to be as simple as possible and I will just use the default up and down buttons provided by it (so that I won't need to design my own). I have two textbox controls to display the value controlled by the updown control. One for month, and another for year. <asp:TextBox ID="txtMonth" runat="server" CssClass="txtNumeric" ReadOnly="True" Width="150px" /> <asp:TextBox ID="txtYear" runat="server" CssClass="txtNumeric" ReadOnly="True" Width="150px" /> So I will now drop 1 numeric updown control for each of the textboxes. <asp:NumericUpDownExtender ID="txtMonth_NumericUpDownExtender"     runat="server" TargetControlID="txtMonth" Maximum="12" Minimum="1" Width="152"> </asp:NumericUpDownExtender>                          <asp:NumericUpDownExtender ID="txtYear_NumericUpDownExtender"     runat="server" TargetControlID="txtYear" Width="152"> </asp:NumericUpDownExtender>                                                  You noticed that I configure the Maximum and Minimum value for the first numericupdown control, but I never did the same for the second one (for txtYear). That's because it won't work, well, at least for me. So I remove the Minimum="2000" and Maximum="2099" from there. Then I would configure the initial value to the the current year, and let the year to flow up and down freely. If you want, you want write the codes to restrict it. Here are the codes I used on PageLoad:     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load         If Not Page.IsPostBack Then             If Trim(txtMonth.Text) = "" Then                 Me.txtMonth.Text = System.DateTime.Today.Month             End If             If Trim(txtYear.Text) = "" Then                 Me.txtYear.Text = System.DateTime.Today.Year             End If         End If     End Sub   Enjoy!

    Read the article

  • How do I use InputType=numberDecimal with the "phone" soft keypad?

    - by Adam Dunn
    For an EditText box, the user should only be entering valid numbers, so I am using android:inputType="numberDecimal". Unfortunately, the soft keyboard that Android brings up has numbers only along the top row, while the next three rows have various other symbols (dollar sign, percent sign, exclamation mark, space, etc). Since the numberDecimal only accepts numbers 0-9, negative sign, and decimal point, it would make more sense to use the "phone" soft keyboard (0-9 in a 3x3 grid, plus some other symbols). This would make the buttons larger and easier to hit (since it's a 4x4 grid rather than a 10x4 grid in the same screen area). Unfortunately, using android:inputType="phone" allows non-numeric characters such as parentheses I have attempted to use android:inputType="numberDecimal|phone", but the numberDecimal aspect of the bit flag seems to be ignored. I have also tried using android:inputType="phone" in combination with android:digits="0123456789-.", but that still allows multiple negative signs or decimal points (inputType="number" has really good error checking for things like that, and won't let the user even type it in). I have also tried using android:inputType="phone" in the xml layout file, while using a DigitsKeyListener in the java code, but then that just uses the default number soft keyboard (the one that has numbers only along top row) (it appears to set InputType.TYPE_CLASS_NUMBER, which voids the InputType.TYPE_CLASS_PHONE set by the xml layout). Writing a custom IME wouldn't work, since the user would have to select the IME as a global option outside the app. Is there any way to use the "phone" style soft keyboard while also using the "number" restrictions on what is entered?

    Read the article

  • Fractional to Decimal Form.

    - by ThePower
    Hi, there probably isn't an answer to this apart from "Create it yourself", but you never know, there might be some string representation for this. Basically, I would like to display number values as fractional instead of decimal when displaying the values as a string. Instead of a value displaying as: 1.1428571428571428571428571428571 I would prefer it to display as 8/7 Is there any way of doing this without writing the functionality myself? Regards Lloyd

    Read the article

  • Why is FLT_MIN equal to zero on OS X?

    - by Nick Forge
    limits.h specifies limits for non-floating point math types, e.g. INT_MIN and INT_MAX. These values are the most negative and most positive values that you can represent using an int. In float.h, there are definitions for FLT_MIN and FLT_MAX. If you do the following: NSLog(@"%f %f", FLT_MIN, FLT_MAX); You get the following output: FLT_MIN = 0.000000, FLT_MAX = 340282346638528859811704183484516925440.000000 FLT_MAX is equal to a really large number, as you would expect, but why does FLT_MIN equal zero?

    Read the article

  • Numerical precision of double type in Visual C++ 2008 Express debugger

    - by damik
    I'm using Visual C++ 2008 Express Edition and when i debug code: double x = 0.2; I see in debugging tooltip on x 0.20000000000000001 but: typedef numeric_limits< double > double_limit; int a = double_limit::digits10 gives me: a = 15 Why results in debugger are longer than maybe ? What is this strange precision based on ? My CPU is Intel Core 2 Duo T7100

    Read the article

  • double precision in Ada?

    - by yCalleecharan
    Hi, I'm very new to Ada and was trying to see if it offers double precision type. I see that we have float and Put( Integer'Image( Float'digits ) ); on my machine gives a value of 6, which is not enough for numerical computations. Does Ada has double and long double types as in C? Thanks a lot...

    Read the article

  • Why is FLT_MIN equal to zero?

    - by Nick Forge
    limits.h specifies limits for non-floating point math types, e.g. INT_MIN and INT_MAX. These values are the most negative and most positive values that you can represent using an int. In float.h, there are definitions for FLT_MIN and FLT_MAX. FLT_MAX is equal to a really large number, as you would expect, but why does FLT_MIN equal zero?

    Read the article

  • Is it possible to read infinity or NaN values using input streams?

    - by Drise
    I have some input to be read by a input filestream (for example): -365.269511 -0.356123 -Inf 0.000000 When I use std::ifstream mystream; to read from the file to some double d1 = -1, d2 = -1, d3 = -1, d4 = -1; (assume mystream has already been opened and the file is valid), mystream >> d1 >> d2 >> d3 >> d4; mystream is in the fail state. I would expect std::cout << d1 << " " << d2 << " " << d3 << " " << d4 << std::endl; to output -365.269511 -0.356123 -1 -1. I would want it to output -365.269511 -0.356123 -Inf 0 instead. This set of data was output using C++ streams. Why can't I do the reverse process (read in my output)? How can I get the functionality I seek? From MooingDuck: #include <iostream> #include <limits> using namespace std; int main() { double myd = std::numeric_limits<double>::infinity(); cout << myd << '\n'; cin >> myd; cout << cin.good() << ":" << myd << endl; return 0; } Input: inf Output: inf 0:inf See also: http://ideone.com/jVvei Also related to this problem is NaN parsing, even though I do not give examples for it.

    Read the article

  • Strange performance behaviour for 64 bit modulo operation

    - by codymanix
    The last three of these method calls take approx. double the time than the first four. The only difference is that their arguments doesn't fit in integer anymore. But should this matter? The parameter is declared to be long, so it should use long for calculation anyway. Does the modulo operation use another algorithm for numbersmaxint? I am using amd athlon64 3200+, winxp sp3 and vs2008. Stopwatch sw = new Stopwatch(); TestLong(sw, int.MaxValue - 3l); TestLong(sw, int.MaxValue - 2l); TestLong(sw, int.MaxValue - 1l); TestLong(sw, int.MaxValue); TestLong(sw, int.MaxValue + 1l); TestLong(sw, int.MaxValue + 2l); TestLong(sw, int.MaxValue + 3l); Console.ReadLine(); static void TestLong(Stopwatch sw, long num) { long n = 0; sw.Reset(); sw.Start(); for (long i = 3; i < 20000000; i++) { n += num % i; } sw.Stop(); Console.WriteLine(sw.Elapsed); } EDIT: I now tried the same with C and the issue does not occur here, all modulo operations take the same time, in release and in debug mode with and without optimizations turned on: #include "stdafx.h" #include "time.h" #include "limits.h" static void TestLong(long long num) { long long n = 0; clock_t t = clock(); for (long long i = 3; i < 20000000LL*100; i++) { n += num % i; } printf("%d - %lld\n", clock()-t, n); } int main() { printf("%i %i %i %i\n\n", sizeof (int), sizeof(long), sizeof(long long), sizeof(void*)); TestLong(3); TestLong(10); TestLong(131); TestLong(INT_MAX - 1L); TestLong(UINT_MAX +1LL); TestLong(INT_MAX + 1LL); TestLong(LLONG_MAX-1LL); getchar(); return 0; } EDIT2: Thanks for the great suggestions. I found that both .net and c (in debug as well as in release mode) does't not use atomically cpu instructions to calculate the remainder but they call a function that does. In the c program I could get the name of it which is "_allrem". It also displayed full source comments for this file so I found the information that this algorithm special cases the 32bit divisors instead of dividends which was the case in the .net application. I also found out that the performance of the c program really is only affected by the value of the divisor but not the dividend. Another test showed that the performance of the remainder function in the .net program depends on both the dividend and divisor. BTW: Even simple additions of long long values are calculated by a consecutive add and adc instructions. So even if my processor calls itself 64bit, it really isn't :( EDIT3: I now ran the c app on a windows 7 x64 edition, compiled with visual studio 2010. The funny thing is, the performance behavior stays the same, although now (I checked the assembly source) true 64 bit instructions are used.

    Read the article

  • PHP is not returning me a number type

    - by Tristan
    Hello, i tryed to follow that great tutorial (STAR rating with css : http://stackoverflow.com/questions/1987524/turn-a-number-into-star-rating-display-using-jquery-and-css) but i've just a big problem : When i do <span class="stars">1.75</span> or $foo='1.75'; echo '<span class="stars">'.$foo.'</span> the stars is correctly shown, but as soon as i do : while($val = mysql_fetch_array($result)) { $average = ($val['services'] + $val['serviceCli'] + $val['interface'] + $val['qualite'] + $val['rapport'] ) / 5 ; <span class="stars">.$average.</span> } the stars stops working i double checked the data type in mysql : they're all TINYINT(2) and i tryed that : $average = intval($average); but it's still not working, Thank you

    Read the article

  • how to make a javascript number keypad popup

    - by user2434653
    i have a website with 3 pages. each page has a form with two input fields. i am trying to make a popup number-keypad that will populate what ever input field called it. below is that base code i keep coming back to. <html> <head><title>test</title></head> <body> <script> function num(id) { return document.getElementById(id); } </script> <form action="/unitPage" method="POST" style=" text-align:center;"> Prefix: <input id="num" name"prefix" type="text" onfocus="num('keypad').style.display='inline-block';"/> Number: <input id="num" name"number" type="text" pattern="[0-9]{6}" onfocus="num('keypad').style.display='inline-block';"/> </form> <div id="keypad" style="display:none; background:#AAA; vertical-align:top;"> <input type="button" value="7" onclick="num('num').value+=7;"/> <input type="button" value="8" onclick="num('num').value+=8;"/> <input type="button" value="9" onclick="num('num').value+=9;"/><br/> <input type="button" value="4" onclick="num('num').value+=4;"/> <input type="button" value="5" onclick="num('num').value+=5;"/> <input type="button" value="6" onclick="num('num').value+=6;"/><br/> <input type="button" value="1" onclick="num('num').value+=1;"/> <input type="button" value="2" onclick="num('num').value+=2;"/> <input type="button" value="3" onclick="num('num').value+=3;"/><br/> <input type="button" value="X" onclick="num('keypad').style.display='none'"/> <input type="button" value="0" onclick="num('num').value+=0;"/> <input type="button" value="&larr;" onclick="num('num').value=num('num').value.substr(0,num('num').value.length-1);"/> </div> </body> </html> is there a way of making one number key pad that i call from any page or do i need to make the above for each input? thanks

    Read the article

  • How can I create an enum using numbers?

    - by Jordan S
    Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to display and set this value. If I were to create an enum like this... private enum GainValues {One, Two, Four, Eight} and I made my gain variable of type GainValues then the drop-down list in the propertygrid would only show the available values for the gain variable. The problem is I want the gain values to read numerically an not as words. But I can not create an enum like this: private enum GainValues {1,2,4,8} So is there another way of doing this? Perhaps creating a custom type?

    Read the article

  • Sort a list numerically in Python

    - by Matthew
    So I have this list, we'll call it listA. I'm trying to get the [3] item in each list e.g. ['5.01','5.88','2.10','9.45','17.58','2.76'] in sorted order. So the end result would start the entire list over again with Santa at the top. Does that make any sense? [['John Doe', u'25.78', u'20.77', '5.01'], ['Jane Doe', u'21.08', u'15.20', '5.88'], ['James Bond', u'20.57', u'18.47', '2.10'], ['Michael Jordan', u'28.50', u'19.05', '9.45'], ['Santa', u'31.13', u'13.55', '17.58'], ['Easter Bunny', u'17.20', u'14.44', '2.76']]

    Read the article

  • MySql Not Like Regexp?

    - by KnockKnockWhosThere
    I'm trying to find rows where the first character is not a digit. I have this: SELECT DISTINCT(action) FROM actions WHERE qkey = 140 AND action NOT REGEXP '^[:digit:]$'; But, I'm not sure how to make sure it checks just the first character...

    Read the article

  • Big numbers with fraction support

    - by dutt
    I need a c# number something that can handle very large numbers but also fraction support, I looked at System.Numberics.BigInteger coming in .NET 4.0 but I can't get it to work with fractions. something i = 2; something j = 5; something k = i/j; //should be 0.4 when i tried BigInteger i = 2; BigInteger j = 5; double d = (double)(i/j); //d is 0.0 Does anybody know such a library?

    Read the article

  • PHP: Is_numeric returns false on 0

    - by Industrial
    Hi everyone, Is_numeric() as well as is_int() returns false if the value is 0. What can i do instead to verify that a specific value is numbers only in PHP? Are we heading straight for the Regular Expressions camp, or are there some nice, handy feature for this out there already? Thanks!

    Read the article

  • What to store at application Settings, numeric / string representations or objects?

    - by SoMoS
    Hello, I've been thinking for a while on what to store at the Project Settings, objects or numeric/string representations of those objects to set a rule and avoid thinking on this at the future so I want to take the best approach. On one side storing object representations grants you that what is stored is valid and saves you from doing conversions each time you access them. You only need objects with the attribute. At the other side storing the numeric/string representation of an object eases the editing of the setting because at the end the user will be entering numeric or string information. What do you do with this issue?

    Read the article

  • Best way to enter numeric values with decimal points?

    - by Andrew Grant
    In my app users need to be able to enter numeric values with decimal places. The iPhone doesn't provides a keyboard that's specific for this purpose - only a number pad and a keyboard with numbers and symbols. Is there an easy way to use the latter and prevent any non-numeric input from being entered without having to regex the final result? Thanks!

    Read the article

  • C++, name collision across different namespace

    - by aaa
    hello. I am baffled by the following name collision: namespace mp2 { boost::numeric::ublas::matrix_range<M> slice(M& m, const R1& r1, const R2& r2) { namespace ublas = boost::numeric::ublas; ublas::range r1_(r1.begin(), r1.end()), r2_(r2.begin(), r2.end()); return ublas::matrix_range<M>(m, r1_, r2_); } double energy(const Wavefunction &wf) { const Wavefunction::matrix& C = wf.coefficients(); int No = wf.occupied().size(); foreach (const Basis::MappedShell& P, basis.shells()) { slice(C, range(No), range(P)); the error from g++4.4 is 7 In file included from mp2.cpp:1: 8 /usr/include/boost/numeric/ublas/fwd.hpp: In function âdouble mp2::energy(const Wavefunction&)â: 9 /usr/include/boost/numeric/ublas/fwd.hpp:32: error: âboost::numeric::ublas::sliceâ is not a function, 10 ../../src/mp2/energy.hpp:98: error: conflict with âtemplate<class M, class R1, class R2> boost::numeric::ublas::matrix_range<M> mp2::slice(M&, const R1&, const R2&)â 11 ../../src/mp2/energy.hpp:123: error: in call to âsliceâ 12 /usr/include/boost/numeric/ublas/fwd.hpp:32: error: âboost::numeric::ublas::sliceâ is not a function, 13 ../../src/mp2/energy.hpp:98: error: conflict with âtemplate<class M, class R1, class R2> boost::numeric::ublas::matrix_range<M> mp2::slice(M&, const R1&, const R2&)â 14 ../../src/mp2/energy.hpp:129: error: in call to âsliceâ 15 make: *** [mp2.lo] Error 1 ublas segment is namespace boost { namespace numeric { namespace ublas { typedef basic_slice<> slice; why is slice in ublas collides with slice in mp2? I and fairly certain there is no using namespace ublas in the code and in includes. thank you

    Read the article

  • How to add a constructor to a subclassed numeric type?

    - by abbot
    I want to subclass a numeric type (say, int) in python and give it a shiny complex constructor. Something like this: class NamedInteger(int): def __init__(self, value): super(NamedInteger, self).__init__(value) self.name = 'pony' def __str__(self): return self.name x = NamedInteger(5) print x + 3 print str(x) This works fine under Python 2.4, but Python 2.6 gives a deprecation warning. What is the best way to subclass a numeric type and to redefine constructors for builtin types in newer Python versions?

    Read the article

  • How to reformat date in PHP?

    - by Lisa
    I am pulling the dates of various posts from a database. The dates are in the following format: 2009-08-12 Numeric Year - Numeric Month - Numeric Day How can I reformat these dates to something more user friendly like: August 12, 2009 Numeric Month Numeric Date, Numeric Year Assuming that the date gotten from the mysql database is stored in a variable called: $date = $row['date_selected'];

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >