double datatype is not assigning large value - double

I am trying to assign a large value to a double datatype for example
double someValue = 36028797018963967D;
but the problem is, when I debug the value of variable someValue, it becomes 36028797018963968D and I cant figure out why.
Any help will be appreciated,
Thanks!

Both of these numbers are the same in 64 bit floating point. What gets printed is an artifact of the method used to print them. Try this:
assert(36028797018963967D == 36028797018963968D)
It works!

Related

How can I change a walkspeed to like a variable

local playerName = OykkoIsBack
Players.(playerName).Character.Humanoid.JumpPower = 100
so I want to set my jump power to the variable that has the players name? im new to roblox
scripting and this happened in my output
Expected identifier, got '('
something similar to this happened
i wrote this if game.Workspace.IntValue.Value = 0 then
print("Value is 0")
but i figured this out by adding a another = but this time i can't figure it out so i need someone to help me!
really appreciate it if you could help me!
OykkoIsBack should have double quotes around it, so the first line should be local playerName = "OykkoIsBack". Without the quotes, it is not a string and cannot be assigned to playerName.
The other issue is with Players.(playerName). The syntax for indexing a table in Lua is table[key]. In your case it should be Players[playerName]
Here is the code
local playerName = "OykkoIsBack"
Players[playerName].Character.Humanoid.JumpPower = 100
What this does is sets playerName to OykkoIsBack, then it gets the humanoid of the player with playerName and sets their jump power to 100.
I’m quite new at scripting too, so I might be wrong but here’s what I think the mistake is:
First of all you put
Players.(playername).Character.Humanoid etc.
I think ‘playername’ shouldn’t have brackets?
Secondly, you just set the jumpPower to 100?? Try replacing the 100 with a variable, so after the = try writing the variable name.
I think this because the error is saying there was a bracket where it expected something else (from what I know) so I think it’s just the playername brackets.

how can you append a number to a double in swift

I am trying to make a calculator app in swift as a practise for my IOS development course. for that app I am trying to append a number to an existing double or integer after the user pressed on a specific button, but I don't know how.
if the user pressed on lets say a 5, then I want that the code should append that 5 to the numbers he pressed before
for instance:
the user has typed the following number:
6797.890
and now he wants to add the 5 to the existing number so that the number would be:
6797.8905
I really don't know how to do this in the code, and I really appreciate it if someone could help me by showing how or giving some resource website's for this problem
thanks a lot!
Benji
I know you mentioned that you are supposed to use an Int or Double, but I would try and use NSDecimalNumber and String if you can. It will give you the precision you want and has a convenient way to turn the string into an NSDecimalNumber, NSDecimalNumber(string: "6797.8905"), as well as back to a string, number.stringValue. You can enteredAmount != NSDecimalNumber.notANumber just in case your user input is incompatible.
You must process the input as a string. If you process it as a double, the trailing zero will be lost and your code will not be able to distinguish between adding "5" to 6797.890 and adding "5" to 6797.89
Only convert from String to Double in one direction (from input to data) after displaying the initial value.

Swift - adding values captured in two textfields

I seem to have a problem with a very simple scenario.
I'm trying to add values captured by two text fields (called T1 and T2) and display their total upon pressing a button (GoButton) on a label (Label1).
I tried wording the syntax in multiple ways and it still doesn't work. I feel that some of the syntax I found on the web didn't work for me. I use Xcode 6.3 on Yosemite.
Screenshot:
Is there a chance that there is something I'm missing with my Xcode to accept swift syntax? Please help.
Dante-
There's still a chance the values could be nil. You've correctly !'ed the TextFields so they unwrap automatically, but the Int conversion is also Optional (the Int still thinks it may get a nil value).
Label1.text = "\(T1.text.toInt()! + T2.text.toInt()!)"
Helpful Hint- If you paste your code in here (rather than a screenshot) it's much easier for folks to copy and paste your code into their IDE and test it out.
For those here smarter than me (everyone) I'm curious why Xcode doesn't complain about a single Int conversion:
Label1.text = "\(T1.text.toInt())" // no complaint from the compiler
Value T1.text.toInt() is an Optional Integer. So you must unwrap it first. So use Label1.text = "\(T1.text.toInt()! + T2.text.toInt()!)"
Good luck
Thats because toInt() returns an optional value. You can cast your String to NSString and extract the integer value without returning an optional.
Label1.text = ((T1.text! as NSString).integerValue + (T2.text! as NSString).integerValue + (T3.text! as NSString).integerValue + (T4.text! as NSString).integerValue).description
Label1.text = "\(T1.text.toInt()! + T2.text.toInt()!)" //T1.text.toInt()
is an optional so you should use ! mark otherwise it will return nil
value

Why can I not store 16 bits in a logic in SystemVerilog?!

I am currently having issues when trying to store a 16bit number coming from the input of my module into one of my logic variables. When I set all the bits high in my test bench I get a value: 0000000000000001. Hope you can help! PS: Sorry, dont know how to insert code on here....
My code is shown below:
http://pastebin.com/cZCYKJqV
I think your problem is likely with this line:
regy = (!regy)+1;
regy is a 16-bit value. Using the negation operator (!) on a multi-bit value is equivalent to (value != 0). So for any value of regy other than zero will set regy to 1.
If you are trying to invert all the bits and add 1, you need to use the ~ operator.
Example:
regy = (~regy)+1;

how to use divide() method in jasper reports?

Im using iReport1.3.3 tool to create pdf and xls template ..
My problem is for the below expression,
($V{strloanNo}).divide($V{loanCalculation})
i need to divide both the variables but i am not getting expected result. it is displaying "null" value .
any idea guys?
$V{x}.divide( $V{y} )
This works for me.
It looks like your variables are Null.
Make sure to set the Initial Value Expression in the variable's properties.
I set both of mine to below.
new java.math.BigDecimal(10.0)
Guess you can try this out -
$V{strloanNo}.floatValue()/$V{loanCalculation}.floatValue()
As it was discussed
here, you can check this:
$F{Attribute_a}.divide($F{Attribute_b}, new MathContext(100))
If your division results in a non-terminating decimal then an exception is thrown. So you scale simply it to something reasonable and exception be gone.
$F{Attribute_a}.divide($F{Attribute_b})
and class type should be java.math.BigDecimal
if attribute b is zero, please put the condition