numbers

Convert/Adjust Number in a specific counting with PHP

浪子不回头ぞ 提交于 2019-12-11 05:49:44
问题 I have the number 1543, I want to make sure that I find the number closest to 1543 which is counted every 100. For eg: 1527 = 1500 1563 = 1600 12034 = 12000 12081 = 12100 I hope that you understand. 回答1: Use the round() function with a precision value of -2 , round( $number, -2); Codepad Viper Demo. 回答2: you can do that by dividing the number by 100 and using the round function. 回答3: <?php function foo($number, $d) { return round($number / $d) * $d; } echo foo(1527, 100) . "\n"; echo foo

Regex: get every number that doesn't has an other number before or after itself

大城市里の小女人 提交于 2019-12-11 05:43:46
问题 The thing that I have to do is to extract every 'single' number, that doesn't has another number right before or after itself. Then I have to replace this number with an number, that is incremented with 1. I now want to a Regex that gets every single number from a string, that doesn't has another number right before or after itself. As example: From this string, I just want the '1': "Klasse 1a 14/15" the result should look like "Klasse 2a 14/15" From this string, I just want the '5': "5/66"

How do generate random numbers, while avoiding numbers already used

给你一囗甜甜゛ 提交于 2019-12-11 05:38:35
问题 How do i generate random numbers but have the numbers avoid numbers already used. I have a TXT file with thousands of sets of numbers and i need to generate a series of random numbers while avoiding these. IE, TXT - 0102030405 my random number needs to avoid this number. on a side note, how can i split up the TXT 10 digit number into 5, two digit numbers? then how can i generate random numbers based off of that. 回答1: You could load up all previously found random numbers into a dictionary,

number of space between each word

核能气质少年 提交于 2019-12-11 05:37:45
问题 How can I find a quick way to count the number of spacing between each word in a text? Each space represents a value, Example: one space is the letter 'a', two spaces is the letter 'b', etc.. An example with the text text : hello all the world one space between hello and all --> 'a', two spaces between all and the --> 'b', ... word --> 'abc' 回答1: import re import string ''.join(map(lambda x: string.lowercase[len(x) - 1], re.findall(r'\s+', 'hello all the world'))) # 'abc' 回答2: For

python class fraction numbers

*爱你&永不变心* 提交于 2019-12-11 05:36:10
问题 I made a code that makes the user input two fraction numbers in the form "d/n". How can I make it print the reduced form of the fraction ? ex: when I type 2/4 it prints 1/2? import sys class Rational: def __init__(self,n,d): self.numerator= n self.denominator= d def value(self): return float(self.numerator)/float(self.denominator) def __repr__(self): return "%d/%d ~ %g" % (self.numerator,self.denominator,self.value()) def read(self): while 1: try: s=raw_input("Enter fraction n/d: ") n,d= s

Using XSLT, how do I increase the value of the 'format' attribute of an <xsl:number> (e.g. 'a'+1 = 'b')?

一笑奈何 提交于 2019-12-11 05:34:25
问题 There are 2321 occurrences of the character 'a' in the element contents of my source XML file. I have succeeded in obtaining this number, but I can only do it for the 'a' character. I need to obtain the occurrences for all the letters of the alphabet. See code: This is used to print out a TextBlock element: <xsl:template name="get-textblock"> <xsl:param name="letter-one"/> <xsl:param name="letter-two"/> <xsl:param name="letter-one-f"/> <xsl:param name="letter-two-f"/> <xsl:if test="$letter

MatLab - variable precision arithmetic

寵の児 提交于 2019-12-11 05:19:50
问题 I have a brief question regarding the vpa command one may use to evaluate symbolic expressions in MatLab. My textbook says the following: "You need to be careful when you use functions such as sqrt on numbers, which by default result in a double-precision floating-point number. You need to pass such input to vpa as a symbolic string for correct evaluation: vpa('sqrt(5)/pi') ." I don't quite understand the jargon here. Why is it that for most inputs I get the exact same answer whether I type

Displaying doubles to a certain precision in java

折月煮酒 提交于 2019-12-11 04:40:44
问题 I am currently writing a calculator application. I know that a double is not the best choice for good math. Most of the functions in the application have great precision but the ones that don't get super ugly results. My solution is to show users only 12 decimals of precision. I chose 12 because my lowest precision comes from my numerical derive function. The issue I am having is that if I multiply it by a scaler then round then divide by the scaler the precision will most likely be thrown

HttpComponents - Connect to different Port

那年仲夏 提交于 2019-12-11 04:39:19
问题 I have to write an android client, in which i should use HttpComponents to connect to a specific Server on Port 8080. For now, all i've found, was the Examplecode from the Apache-site, which is nearly perfect for what i need, except the Port it connects to: if (isSet) { throw new IOException("Hostname or Port are not set!"); } HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(serverURL + ":" + serverPort + "/maps"); HttpResponse response = httpclient.execute

Comma Automatically Being Added to TextField in Swift

给你一囗甜甜゛ 提交于 2019-12-11 04:05:01
问题 I'm working on a status bar application. Currently all I have is a drop down menu that either quits the app or opens a preferences window. There is a textfield in the window that will be for a number value. While testing I noticed that when I used .orderOut to hide the window a comma would appear in my number. No idea why this is happening or what I can do to stop it (I am very new to Swift) @IBOutlet weak var statusMenu: NSMenu! @IBOutlet weak var prefWindow: NSWindow! @IBOutlet weak var