numbers

Display SQL query results in php

时光毁灭记忆、已成空白 提交于 2019-11-30 08:31:46
问题 I'm tring to diplay results in php from sql database MySQL statement is correct and does what i want in phpMyAdmin but for some reason my code breaks in the webpage here is the code require_once('db.php'); $sql="SELECT * FROM modul1open WHERE idM1O>=(SELECT FLOOR( MAX( idM1O ) * RAND( ) ) FROM modul1open) ORDER BY idM1O LIMIT 1" $result = mysql_query($sql); echo [$result]; and here is what i get In general I need random number limited from min to max by the table id 回答1: You need to fetch the

Java library to check whether a String contains a number *without* exceptions

橙三吉。 提交于 2019-11-30 08:27:17
问题 I'm looking for a method that returns a boolean if the String it is passed is a valid number (e.g. "123.55e-9", "-333,556"). I don't want to just do: public boolean isANumber(String s) { try { BigDecimal a = new BigDecimal(s); return true; } catch (NumberFormatException e) { return false; } } Clearly, the function should use a state machine (DFA) to parse the string to make sure invalid examples don't fool it (e.g. "-21,22.22.2", "33-2"). Do you know if any such library exists? I don't really

Don't allow typing alphabetic characters in a <input type=number />

对着背影说爱祢 提交于 2019-11-30 08:20:12
I need to have a textbox, where, whenever typed inside should ONLY allow numbers [0-9]. I've used type="number" which definitely holds the client side validation but also allows to type other alphabets. I can do it by tracking each keydown and matching with regex but I was wondering if there is any way I can restrict to type using only html tags and NOT defining any functions in JavaScript to compare in each keydown? Code not sufficient to do so is: <input type="number" id="txt_number" maxlength="70" name="txt_name" placeholder="Number"> Any help is appreciated. mihai.ciorobea You can use

How to express numbers in scientific notation in java? [duplicate]

我的梦境 提交于 2019-11-30 08:07:11
This question already has an answer here: Format double value in scientific notation 4 answers I'm writing a program that deals with planets' mass and diameter; These quantities are expressed in scientific notation. My question is NOT, mind you, NOT how does one print large numbers the right way (That's using printf(), duh), its how I would... "type" these numbers, I guess you could say. For example, the mass of mercury is expressed: 3.30 x 10ˆ23 And in my array of planet masses, an element would look: 33.0 * Math.pow(10, 23) However, I don't quite think this is the right way - it looks like

c++ pow(2,1000) is normaly to big for double, but it's working. why?

烂漫一生 提交于 2019-11-30 08:06:11
问题 the code: #iclude <math.h> int main(){ double somenumber = pow(2, 1000); printf("%lf\n", somenumber); return 0; } i get this huge number: 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376 This is obviously to big for double. How it's working?

C++ Get Total File Line Number

痞子三分冷 提交于 2019-11-30 07:34:56
问题 Is there a function I can use to get total file line number in C++ , or does it have to be manually done by for loop? #include <iostream> #include <ifstream> ifstream aFile ("text.txt"); if (aFile.good()) { //how do i get total file line number? } text.txt line1 line2 line3 回答1: There is no such function. Counting can be done by reading whole lines std::ifstream f("text.txt"); std::string line; long i; for (i = 0; std::getline(f, line); ++i) ; A note about scope, variable i must be outside

Extended Precision Floating Point Library C/C++

我的未来我决定 提交于 2019-11-30 07:28:44
I am looking for an extended precision floating point library with the following features: fixed data type size (i.e. the extended precision float takes a fixed amount of memory) no initialization required for variables specify size of both mantissa and exponent C/C++ interface support for really large floats > 10^10000 The closest I could found is the HPA library by Ivano Primi. The only problem with this library is that I cannot extend the exponent (it is fixed with 15 bits). It allows me various choices for the mantissa, but the largest representable number is always limited to 10^4932.

UITextField - Allow only numbers and punctuation input/keypad

萝らか妹 提交于 2019-11-30 07:25:29
I have tried the code below but that only allows for numbers on the keypad to be inputted. My app requires the keypad to use a period/full stop (for money transactions). The code I tried is: - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSCharacterSet *nonNumberSet = [[NSCharacterSet decimalDigitCharacterSet] invertedSet]; if ([string rangeOfCharacterFromSet:nonNumberSet].location != NSNotFound) { return NO; } return YES; } Thanks for any help. Kalpesh Try this Make a macro #define ACCEPTABLE_CHARACTERS @

Check if a string contains numbers

偶尔善良 提交于 2019-11-30 07:20:42
问题 How do I check if a string in a MySQL field contains a number then delete them? Example table: tbl_tags ------------- | id | tag | ------------- | 1 | hello | | 2 | hello2 | | 3 | 2hello | | 4 | hel3lo | ------------- The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc. But there must be an easier way? 回答1: Check out the MySQL Regex methods. Something like the following should work. SELECT * FROM table WHERE tag REGEXP '[0-9]' 回答2: SELECT * FROM

Numeric Captcha for PHP

你。 提交于 2019-11-30 07:19:17
问题 Is there a numeric captcha available for PHP ? ( which doesn't rely on JavaScript being turned on ) EDIT: I know there are JS-independent captchas out there. I know there are PHP captchas out there. I know there are numeric captchas out there. But I'm looking for a PHP numeric Javascript-independent captcha. The only numeric captcha's I've found are either for ASP.NET or jQuery/JS based ones. I don't want any of those as an answer to the question. And I'm not taking about a small website here