VueJS int Props changing value on prefix with 0 - properties

I am trying to pass through an int value as a prop.
So if I call:
<job-cards-create :jobno="1203"></job-cards-create>
I get:
But if I add even one '0' infront:
<job-cards-create :jobno="01203"></job-cards-create>
It gives:
What is going on? Am I missing something?

This is because your number 01203 is being interpreted as an octal number due to the leading zero. Check out these examples:
01203 === 643 // true
01203.toString() // "643"
Here is some documentation on octals in JS

Do you really need it to be a number? It doesn't look like you're going to be performing any calculations on it. Just knock off the v-bind and use a string literal instead:
<job-cards-create jobno="01203"></job-cards-create>

Related

How can I set a minimal amount of numbers after the decimal dot (0.9=>0.90)

I'm using google bigquery, and a column has values I want to round. If I do, and the rounded value ends in a zero, the zero is not displayed.
I've tried the function FORMAT, which apparently has some .number function, but I have no idea how to use it. Whenever I include any 2 things separated by a comma inside its brackets, it complains that it only takes 1 value.
You would use FORMAT() with the precision specifier. For four decimal places always -- including zeros:
select format('%.4f', 1.23)
If the BQ documentation does not answer your questions, I find that that the function seems to be inspired by the classic C printf()/sprintf() functions.
Unaware if in BigQuery (haven't used it ever) there is a better way I guess this will fix your problem since I just tried it in their console.
Cast your float to a string and then check if your last digit is a 0. In case it's not add it:
SELECT case when RIGHT(cast(0.9 as string), 1) <> '0' then cast(0.9 as string)+'0' else cast(0.9 as string) end as FormattedNumber

I need to minus some value from a fixed number in jsf

I need to minus some value (value coming from DB though Databean and VO) here is my code:
value="200 - #{pc_costReportDataBean.adjustCostVo.explanationLength}"
but the problem is result coming like [200-0].
Try:
value="#{200-pc_costReportDataBean.adjustCostVo.explanationLength}"
The #{} means that the whole expression inside will be evaluated. The values outside will be just treated as Strings.

onChange Javascript to round this.value

I've got the following onChange code. It updates my div1 with the value. The value is a numeric value and I would like to round it so that there is no decimal point. Can anyone tell me how this can be done?
So for example value 12.987654321 will be 13
onChange="document.getElementById('div1').innerHTML=this.value"
There is a Math.round function you could use like this (otherwise your code looks fine to me):
onChange="document.getElementById('div1').innerHTML=Math.round(+this.value)"

How to set default value of variable in live template in Intellij IDEA?

There could be a little misunterstanding in live templates in Intellij IDEA. I mean default values for variables in templates.
Suppose we have this live template
What I expect here, that when calling this template (type jqon and press TAB) I will see default values already typed which I can change or leave as it is. Like this
But no. I have empty strings instead of default values
Why?
I was wrong about Default value field. I don't need this in my case. I need to fill Expression field.
If I want just paste some string as default value I should put this string in quote in Expression. So now my variable settings look this way
And everything works how I want!
If you want a hardcoded string as the default value field (in the edit variables dialog), it needs to be in double quotes ("ii"). Putting a string there with no quotes (ii) does not result in an error, but also does not work.

Objective C: Parsing JSON string

I have a string data which I need to parse into a dictionary object. Here is my code:
NSString *barcode = [NSString stringWithString:#"{\"OTP\": 24923313, \"Person\": 100000000000112, \"Coupons\": [ 54900012445, 499030000003, 00000005662 ] }"];
NSLog(#"%#",[barcode objectFromJSONString]);
In this log, I get NULL result. But if I pass only one value in Coupons, I get the results. How to get all three values ?
00000005662 might not be a proper integer number as it's prefixed by zeroes (which means it's octal, IIRC). Try removing them.
Cyrille is right, here is the autoritative answer:
The application/json Media Type for JavaScript Object Notation (JSON): 2.4 Numbers
The representation of numbers is similar to that used in most programming languages. A number contains an integer component that may be prefixed with an optional minus sign, which may be followed by a fraction part and/or an exponent part.
Octal and hex forms are not allowed. Leading zeros are not allowed.