MPS Double values as Concect propterties - mps

Trying to add a double property to my Concept:
concept Location extends BaseConcept
....
properties:
longitude : double
latitude : double
I know that properties is looking for PrimitiveDataTypeDeclaration, but I just find there integer, strings and boolean.
How can I add doubles?

Use the _FPNumberString type to hold double values in properties

Related

Fixed memory allocation for user defined types in vba

i have a User defined type in VBA (Excel) and want to have a fixed memory layout for the members so that I can use pointers in a later step for accessing those members.
The user defined type is looking like the code provided and I need to pass on the adresses of the members to a different programm.
I expected VBA to structere the members in the order that they are initialized but somehow it doesn't.
If you have any idea on how to solve that problem I would be really grateful!
Best Regards,
Lars
Public Type ExampleSet
Example_P_Anteil As Single
Example_I_Anteil As Single
Example_D_Anteil As Single
Example_v0 As Double
Example_Gang0 As Integer
Example_Beschleunigung As Double
Example_Startzeit As Double
Example_int1 As Integer
Example_int2 As Integer
Example_int3 As Integer
End Type
I challenge your conclusions.
Public Type TestUDT
SomeInteger As Integer ' Int16 (I2) at offset 0, padded with 2 bytes
SomeLong As Long ' Int32 (I4) at offset 4, no padding
AnotherLong As Long ' Int32 (I4) at offset 8, no padding
End Type
Public Sub test()
Dim udt As TestUDT
Debug.Print VarPtr(udt) 'expected: X
Debug.Print VarPtr(udt.SomeInteger) 'expected: X+0
Debug.Print VarPtr(udt.SomeLong) 'expected: X+4
Debug.Print VarPtr(udt.AnotherLong) 'expected: X+8
End Sub
Output is as expected:
723094616
723094616
723094620
723094624
User-Defined Types (UDT) are defined in the language specifications as:
A linear concatenation of the aggregated data values possibly with implementation defined padding between data values.
The padding might be what's throwing you off, but a UDT is still a linear concatenation of its members.
Use the LenB function to determine the length of a member (or of the UDT as a whole):
Dim foo As ExampleSet
Debug.Print VarPtr(foo), LenB(foo)
If the UDT contains strings, define them as fixed-length if the offsets of the members that follow it need to be fixed:
Public Type TestUDT
SomeString As String * 10
'...
End Type
That said, good luck accessing these pointers out of process.

Groovy : String to float Conversion

Used code below to save value for float
domainInstance.standardScore = params["standardScore"] as float
In this case my input was given as 17.9 and in db2 database saving as 17.899999618530273 but I want to save as 17.9 itself, let me know how to do it
You can't set precision to a Float or Double in Java. You need to use BigDecimal.
domainInstance.standardScore = new BigDecimal(params["standardScore"]).setScale(1, BigDecimal.ROUND_HALF_UP);
The method BigDecimal.setScale(1, ...) limits decimal to one place only. The second parameter is the rounding strategy.
You need to use BigDecimal to do Conversion from String, then BigDecimal(value).floatValue() to get float, You can do this on more that one way, examples
1 - Using setScale in BigDecimal
def temp = new BigDecimal(params["standardScore"]).setScale(1, BigDecimal.ROUND_HALF_UP)
2- Using DecimalFormat
DecimalFormat df = new DecimalFormat("#.0");
def temp = new BigDecimal(df.format(params["standardScore"] ))
Then you need to get the float value
domainInstance.standardScore = temp.floatValue()

Regex for double in Hyperledger Modeling languager

Is there a way to validate currency in Hyperledger, I am aware that it is possible to validate String values using regex, but I get an error when using regex for Double data type.
Here is what gives an error, it complains about the one line in the Customer defination
participant Customer{
o Double balance regex=/^[0-9]+(\.[0-9]{1,2})?/
}
But this works (If the data type is String instead of Double)
participant Customer{
o String balance regex=/^[0-9]+(\.[0-9]{1,2})?/
}
Regular expressions are only valid for Strings in Composer.
Double, Long or Integer fields may include an optional range expression, which is used to validate the contents of the field.

How to add two decimal numbers

I have three edit texts in which if I put decimal numbers like 23.5 +23.5 and click calculate the app crashes and if I put 235000 +235000 it gives correct results what should be the correct codes for decimal number ,I am new to all this please forgive me for my mistakes`
#TargetApi(Build.VERSION_CODES.N)
public void onButtonClick(View v){
double tys=Integer.parseInt(Tys.getText().toString());
double lys=Integer.parseInt(Lys.getText().toString());
double tgt=Integer.parseInt(Tgt.getText().toString());
double sum=((int)tys-lys)/lys*100;
DecimalFormat precision = new DecimalFormat("0.0");
// dblVariable is a number variable and not a String in this case
GrowthResult.setText(precision.format(sum)+"%");
double sum2 =((int)tys/tgt)*100;
achievementResult.setText(precision.format(sum2)+"%");
double sum3 =((int)tys-lys);
JumpResult.setText(precision.format(sum3));
`
You can take data types like float type.then you will get correct answer
float a;
float b;
Edit text data parse in float type then you will get correct answer

SharePoint - what type is Number field

I have a Field, that has Type="Number". What type of variables can I assign to it?
Will the field support float or double?
oListItem["numberField"] = data;
What type can data be?
All values that's string representation can be parsed as double, since SharePoint converts the input value to a string:
case SPFieldType.Number:
case SPFieldType.Currency:
str1 = Convert.ToString(value, (IFormatProvider) CultureInfo.InvariantCulture);
break;
(from SPListItem.SetValue(...))
You should be fine with string, int, double, etc.

Resources