String to double bpel - bpel

It's possible to convert a string to a double variable
<bpel:to part="parameters" variable="ConvPLRequest">
<bpel:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath1.0">
<![CDATA[ns0:Temperature]]>
</bpel:query>
</bpel:to>
ns0:Temerature it's a string but I need a double.

Did you tried number() bpel conversion function?
Converts input a number. A string that consists of optional whitespace followed by an optional minus sign followed by a Number followed by whitespace is converted to the IEEE 754 number that is nearest (according to the IEEE 754 round-to-nearest rule) to the mathematical value represented by the string; any other string is converted to NaN. boolean true is converted to 1; boolean false is converted to 0. A node-set is first converted to a string as if by a call to the String function and then converted in the same way as a string parameter. Usage: number(input as string or boolean or node-set) Example: number('12.3') returns 12.3

Related

How can string be converted to number in xceptor

What enrichment/formula is required to convert a string to number in Xceptor. I tried FormatNumber
You would need to add a calculation enrichment and then use the DECIMAL([string field]) function - description for this is - DECIMAL: Converts a text string to a decimal.
You can use the INTEGER function to convert a string to an integer
For example, TestInteger = INTEGER("7600")
More information can be found here Xceptor Docs - INTEGER Function

Cast String to Double using Postgresql

How can I cast a string containing double value to numeric value, keeping precision. If the string is not a double, then convert to zero
This query uses a regex match to return a double if the input string has "numeric content", also only digits or decimal numbers with a point as separator like 1.0, 18789.903. Returns 0 if the input string contains non numerics characters like 10hghj. The minus character in front of the string is allowed (negative double):
-- returns 1.2143
WITH subquery AS (SELECT '1.2143'::text as value)
SELECT
CASE WHEN value ~ '^(-)?[0-9]+\.?([0-9]+)?$'
THEN value::double precision
ELSE 0
END FROM subquery;
-- returns 0 because input is a contains not digits characters
-- (the regex expression is the same)
WITH subquery AS (SELECT '1214gh'::text as value)
SELECT
CASE WHEN value ~ '^(-)?[0-9]+\.?([0-9]+)?$'
THEN value::double precision
ELSE 0
END FROM subquery;
Explanation:
The ~ is the regex match operator in PostgreSql. More info here: http://www.postgresql.org/docs/9.4/static/functions-matching.html#FUNCTIONS-POSIX-TABLE
The CASE WHEN THEN ELSE expression allows you to change returned value depending on one or more conditions. In the WHEN part are all statements allowed which return a boolean value. More info: http://www.postgresql.org/docs/9.4/static/functions-conditional.html

How to check if there's only numbers in string

how to check if there is only numbers in the string?
I want to skip some code with goto if there's only numbers in the string.
Thanks
try
i := StrToInt( str );
except
{ str is NOT an integer }
end;
A simple google: Pascal Help
StrToInt
Convert a string to an integer value.
Declaration
Source position: sysstrh.inc line 113
function StrToInt( const s: string ):Integer; Description
StrToInt will convert the string Sto an integer. If the string
contains invalid characters or has an invalid format, then an
EConvertError is raised.
To be successfully converted, a string can contain a combination of
numerical characters, possibly preceded by a minus sign (-). Spaces
are not allowed.
The string S can contain a number in decimal, hexadecimal, binary or
octal format, as described in the language reference. For enumerated
values, the string must be the name of the enumerated value. The name
is searched case insensitively.
For hexadecimal values, the prefix '0x' or 'x' (case insensitive) may
be used as

Arduino issue: String to float adds two zeros instead of the correct integer

Code snippet:
Serial.println(sensorString); //so you can see the captured string
char carray[sensorString.length() + 1]; //determine size of the array
Serial.println(sizeof(carray));
sensorString.toCharArray(carray, sizeof(carray)); //put sensorString into an array
float sensorStringFloat = atoi(carray); //convert the array into an Integer
Serial.println(sensorStringFloat);
Serial.println(sensorStringFloat) prints out 5.00 instead of the correct float value of 5.33. Why is that and how do I fix this issue? I would eventually like to pass sensorStringFloat over to:
aJson.addNumberToObject(sensor, "ph", sensorStringFloat);
atoi converts a numeral in ASCII to an integer. The comment on that line also says it converts to an integer. So you got an integer result, 5. To convert to floating-point, consider using atof. (Note that “f” stands for floating-point, not “float”. atof returns a double.)
you should pass another parameter which defines the format, in this case it is the number of digits after the floating point.
Serial.println(sensorString,2);
String temp = String (_float, 0);
say float x;
convert to String using
String _temp = String(x, 0);
The second parameter 0... says i want no trailing zeros.
Caution: However this is only suitable for whole numbers.
This solution would not work for say... 1.24
You'll get just 1.

Convert a string to a hexadecimal number saved in a int variable

I need a function that can convert a string containg numbers to a hexadecimal integer saved in an integer variable,
for example the function atoi(char*) converts the string in that string into a decimal number , what i need is something similar but instead of decimal , hexadecimal
All integers store data in the same format: binary. That is neither decimal or hexadecimal.
If you want to create a string from an integer, that's when you can decide if you want decimal or hexadecimal notation.
You didn't mention what language you are using so I'll just assume C or C++ from the atoi() reference. There is also an itoa() function. It will create a string from an integer, and you can specify if the string will be created using base 16, base 10, or something else.

Resources