I use Jira 4.0
Jira has a meaning on numeric textbox.
I'm checking in the Groovy Script this space and I assign a variable as below.
value = (String)WorkflowUtils.getFieldValueFromIssue(issue, WorkflowUtils.getFieldFromKey("customfield_10507")) ?: ""
If the value I assign to “value” variable, which is written on customField, is greater than 200 as shown above, it should execute.
Example:
if (value > 200)
{}
else if (value < 200)
{}
My issue is that it detects it as smaller than 200 if the first digit of the number is smaller than 2, such as:
value = 10 – 100 – 150 – 165 – 1000
For instance; When I type 45,30,50,89 it accepts it as greater than 200
You need to cast the value to Integer. Use toInteger() method on non-empty String object.
It should be something like:
def value = (String) WorkflowUtils.getFieldValueFromIssue(issue,WorkflowUtils.getFieldFromKey("customfield_10507"))
def valueNum = value?.isNumber() ? value.toInteger() : 0//You may change the default value
Solution:
value = '56.0'
value2 = value.replace(".0", "");
int convertedNumber = Integer.valueOf(value2).intValue()
if (convertNumber > 200)
{}
else if (convertNumber < 200)
Related
local str = ",23,4"
local t = {}
local i = 1
for temp in str:gmatch("[^,]+") do
t[i] = temp
i = i + 1
end
I'm a Lua newbie. Here is my code. I expected that t[1] has nil. However, gmatch() skipped it instead of returning nil. Tabel t[] has only two key-values. If I make table t[] like this
t[1] = nil
t[2] = 23
t[3] = 4
, how do I use gmatch()? Or what function do I have to use?
gmatch() didn't skip anything; it did exactly what you told it to: it found every occurrance of "[^,]+", of which there are two, and handed each of them to the loop body.
If you want to match empty strings as well, you can change your pattern to "[^,]*".
+ matches one or more
* matches zero or more
Please refer to https://www.lua.org/manual/5.3/manual.html#6.4.1
I have tried to write a small program that converts a decimal to binary that doesn't use the inbuilt function that do that. My program won't convert anything over 12287. 12288 just spits out an infinite loop. Where have I gone wrong? why can't I get above 12287?
while (number != 1) or (number != 0):
a = number // 2
b = number % 2
number = a
if b == 0:
output = "0" + output
if number == 1:
output = "1" + output
break
else:
output = "1" + output
You just need to change the condition from:
while (number != 1) or (number != 0):
To:
while number != 0:
Other than that, your code looks OK. Here is a more streamlined version of the same basic idea:
output = ""
while number:
number, b = divmod(number, 2)
output = str(b) + output
For 12288, number eventually becomes 0. This means while condition is always True.
Note that b becomes 0, so number will stay at 0.
I have and array from string.
When I get the values from string then I split the string so I get an array.
If I give in command:
.command 12 Test 1 Test1 2 Test3 and so on
Then I get: ['12', 'Test', '1', 'Test1', '2', 'Test3']
This is good but I don't know how to check 12, 1, 2 if it is integer or normal text and if after the numbers someone gave text too or not.
Of course I could do in If statement but it would be long code then.
So I need check first value is number or not
I need check if the first value given then the member gave to bot a text too or not.
Third value if it is number or not
Fourth value given or not if the number given
And so on.
How can I do that?
This will check you the first number if it's a number or not. If yes then it will check the next value if it's a string or not. I hope it helps.
for (let i = 0; i < result.length; i += 2) {
if (isNaN(result[i])) {
// not a number
} else {
if (typeof result[i+1] == 'string') { // 2nd value is a text }
else { // 2nd value not a string }
}
}
base = (.75)
hood = (.70)
pipeAura = (.9)
cloak = (.85)
glimmer = (.85)
null = (.78)
heap = (.88)
corrosive = (.75)
spiritBear = (.67)
spellShield = (.5)
berserkersBlood = (.5)
pipe = hood * pipeAura
antimage = spellShield * base
viper = corrosive * base
huksar = berserkersBlood * base
meepo = (.65) * base
veil = (1.25)
pudge = heap * base
input1 = input('What hero are you trying to kill?(antimage, viper, huskar, meepo, pudge)')
input2 = input('What item is the hero holding/using/affected by? (hood, pipeAura, cloak, glimmer, pipe, veil)')
input3 = input('is the hero affected by null field? (yes/no)')
userHealth = input("what is the hero's current hp?")
if input3 == null:
null = (.78)
else:
null = 1
magicResist = (1 - (input1) * (input2) * (null))
The context of many of these names and the idea may not make sense to many of you, but my problem is when i finish giving the input, it gives me the error" magicResist = (1 - (input1) * (input2) * (null))
TypeError: can't multiply sequence by non-int of type 'str'" I need help with this, and i am wondering why it considers them strings, even though all of the inputs trace back to floats with the defined variables
Input returns strings since python2. Before this raw_input returned a string and input returned the evaluated value.
If you want your input be evaluated you could combine input with eval.
inputN = eval(input("message..."))
But you should set the locals and globals passed to eval, to allow specific values or as security-reasons.
Input returns a string. If you want the user to enter a string (in your example that would be the name of the hero or the item) and want to use the appropriate value you calculated before, you might use a dictionary:
# [...]
antimage = spellShield * base
viper = corrosive * base
# [...]
heroes = {
'antimage': antimage,
'viper': viper,
# and so on
}
input1 = input('What hero are you trying to kill?(antimage, viper, huskar, meepo, pudge)')
hero = heroes.get(hero, 1) # I specify 1 as the default if the key is not present in the dictionary, you might specify a more suitable value
Do the same for the items and you can use the variables to calculate the result:
magicResist = (1 - hero * item * null)
how to convert decimal to binary by using repeated division in python?
i know i have to use a while loop, and use modulus sign and others {%} and {//} to do this...but i need some kind of example for me to understand how its done so i can understand completely.
CORRECT ME, if I'm wrong:
number = int(input("Enter a numberto convert into binary: "))
result = ""
while number != 0:
remainder = number % 2 # gives the exact remainder
times = number // 2
result = str(remainder) + result
print("The binary representation is", result)
break
Thank You
Making a "break" without any condition, makes the loop useless, so the code only executes once no matter what.
-
If you don't need to keep the original number, you can change "number" as you go.
If you do need to keep the original number, you can make a different variable like "times".
You seem to have mixed these two scenarios together.
-
If you want to print all the steps, the print will be inside the loop so it prints multiple times.
If you only want to print the final result, then the print goes outside the loop.
while number != 0:
remainder = number % 2 # gives the exact remainder
number = number // 2
result = str(remainder) + result
print("The binary representation is", result)
-
The concatenation line:
Putting the print inside the loop might help you see how it works.
we can make an example:
the value in result might be "11010" (a string, with quotes)
the value in remainder might be 0 (an integer, no quotes)
str(remainder) turns the remainder into a string = "0" instead of 0
So when we look at the assignment statement:
result = str(remainder) + result
The right side of the assignment operator = is evaulated first.
The right side of the = is
str(remainder) + result
which, as we went over above has the values:
"0" + "11010"
This is string concatenation. It just puts one string on the end of the other one. The result is:
"0 11010"
"011010"
That is the value evaluated on the right side of the assignment statement.
result = "011010"
Now that is the value of result.
B_Number = 0
cnt = 0
while (N != 0):
rem = N % 2
c = pow(10, cnt)
B_Number += rem * c
N //= 2
# Count used to store exponent value
cnt += 1
return B_Number