Getting the integer part of a float?
This sure is a simple problem, but i couldn't find an appropriate methode or class so i just like to aks you, wheter you have an idea:^
how do i get the integer part of a float? i mean, how do i get the "14" from the float "14.45698"?
Sounds like you need to explicitly cast it to an integer, like this:
double number1 = 14.45698;
int number2 = 0;
number2 = (int) number1;
Hope this helps.
Similar Messages
-
How do you get the integer of a number with more than 10 digits
I can't seem to be able to get the integer of a number with more than 10 digits.
ex:
integer(12345678901.3) returns -539222987 when it should really return 12345678901
Thanks for the help
(I'm on director 11 at the moment)You can write a Parent script to represent Big Integers. I wrote some code to get you started. It consist of two classes - "BigInt" and "Digit". At this point you can only add two "BigInts" and print out the value with a toString() function. Note that you pass a String to the "BigInt" constructor.
In the message window you could enter something like:
x = script("BigInt").new("999999999999")
y = script("BigInt").new("100000000000000000004")
z = x.add(y)
put z.toString()
And the output window will show:
-- "100000001000000000003"
Here are the two Parent scripts / Classes
-- Digit
property val
property next
on new me, anInt
val = anInt
next = 0
return me
end new
-- BigInt
property Num
property StringRep
on new me, aString
Num = script("Digit").new(Integer(aString.char[aString.length]))
curNum = Num
repeat with pos = aString.length - 1 down to 1
curNum.next = script("Digit").new(Integer(aString.char[pos]))
curNum = curNum.next
end repeat
return me
end new
on add me , Num2
curNum = Num
curNum2 = Num2.Num
result = curNum.val + curNum2.val
if result > 9 then
carry = 1
else
carry = 0
end if
result = result mod 10
sum = script("Digit").new(result)
curSum = sum
curNum = curNum.next
curNum2 = curNum2.next
repeat while curNum.ObjectP AND curNum2.ObjectP
result = curNum.val + curNum2.val + carry
if result > 9 then
carry = 1
else
carry = 0
end if
result = result mod 10
curSum.next = script("Digit").new(result)
curSum = curSum.next
curNum = curNum.next
curNum2 = curNum2.next
end repeat
repeat while curNum.ObjectP
result = curNum.val + carry
if result > 9 then
carry = 1
else
carry = 0
end if
result = result mod 10
curSum.next = script("Digit").new(result)
curSum = curSum.next
curNum = curNum.next
end repeat
repeat while curNum2.ObjectP
result = curNum2.val + carry
if result > 9 then
carry = 1
else
carry = 0
end if
result = result mod 10
curSum.next = script("Digit").new(result)
curSum = curSum.next
curNum2 = curNum2.next
end repeat
StringRep = ""
me.makeString(sum)
return me.script.new(StringRep)
end add
on toString me
StringRep = ""
me.makeString(Num)
return StringRep
end toString
on makeString me, digit
if not digit then
return
end if
me.makeString(digit.next)
put String(digit.val) after StringRep
end makeString -
I purchased an upgrade to photoshop premier elements 11 and photoshop elements 11. I only received the download for premier elements. where do I get the photoshop part?
you can download here: http://www.adobe.com/cfusion/tdrc/index.cfm?product=photoshop_elements
-
Fix the integer part in a decimal numer
i copy the following code from this forum
import java.awt.*;
import java.text.*;
import javax.swing.*;
import javax.swing.text.*;
public class Decimal1
public static void main(String[] args)
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(200,130);
f.setLocation(400,300);
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
f.getContentPane().add(panel);
DecimalFormat df = new DecimalFormat("0.00");
NumberFormatter nfr= new NumberFormatter(df);
nfr.setAllowsInvalid(false);
JFormattedTextField ftf = new JFormattedTextField(nfr);
JLabel lFtf = new JLabel("JFormattedTextField");
JLabel lTf = new JLabel("JTextField");
JTextField tf = new JTextField(8);
panel.add(lFtf);
panel.add(ftf);
panel.add(lTf);
panel.add(tf);
f.setVisible(true);
}i want the user to input the price (the format "99999.99", the integer part is less than 5 digits. the decimal part is fixed to 2 digits)
for example 56.45, 0.67 12345.99 , 88888.12 are accepted.
if the integer part is more than 5 is not allowed.
for example 123456.45, 651433.44
i try it with Document, buy it cannot work together.
how can i to solve it?
thank you!You might want to start looking at [url http://forum.java.sun.com/thread.jspa?threadID=5164412&messageID=9629730#9629730]the threads you've previously started on the topic.
-
Hi, I have a Apple A1083 Cinema Hd Display 30" Widescreen with a broken lcd, where can I get the replacement part ?
Hi, I have a Apple A1083 Cinema Hd Display 30" Widescreen with a broken lcd, where can I get the replacement part ?
-
Get the web part properties of documeny lib view web part using power shell
Hi,
Am looking to get the propeties of a list view web part - a document library's list view web part- using PowerShell
Manually I am able to do the same: the steps followed by me is given below:
1) I went to the
http://srvr1:123/sites/enggtest/mydoclib1/forms/allitems.aspx
2) Edit the page
3) Edit the mydoclib1 view web part
4) go to the peroperties
5) Check the Server Render checkbox
is there anyway i can do this using power shell.The code below assumes that the webpart is at index 0:
$SiteUrl = "http://aissp2013/sites/TestSite/"
$pageURL = "http://aissp2013/sites/TestSite/Lists/MyList/AllItems.aspx"
$web = Get-SPWeb $SiteUrl
$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wp = $wpm.WebParts[0]
$wp.ServerRender = $true
$wpm.SaveChanges($wp)
Blog | SharePoint Learnings CodePlex Tools |
Export Version History To Excel |
Autocomplete Lookup Field -
Instead of getting the drop-down menu that you click, I am getting the old horizontal line with File Edit View History Bookmarks Tools Help
But the little home page icon is on the far right, and (I hope) the awesome bar is working properly. This happened after a Windows Service Pack update, I think, although no one at HP tech support has an answer for me. Everything worked fine for a week, then the update, then the hybrid change. I even uninstalled the Firefox 4.0 and reinstalled it. It's still not displaying properly. Thanks for your helpI advise to reply to the one you want to reply to.
You have had good information here. I will not repeat that here.
I would like to add:
you have incompatible software: start in SafeMode, read Woodmeister and see if it is free of issues.
Akamai is crap software needed or not, Huawei the same.
It is very possible that the keygenerator you used for generating a key for some softwares has infected your mac.
The non-regular software with the false key(s) are not compatible probably or generate malware. Luckily you can not update them automatically because the keygenerator blocked the software for contacting the developer... I propose to consider getting rid of those softwares by really good uninstalling.
You have a beautiful mac, don't degenerate it with crapped software. There are alternatives for expensive software, for example Adobe Photoshop has a free alternative (with a less beautiful interface) in GIMP. And so on.
Lex -
Can't get the random part of the rotation
I'm trying to get a movie clip to start at a random rotation
when you click on a button. I got everything to work when the
random rotation part is not included.
Anytime I try to include the random code I get this error:
"1180: Call to a possibly undefined method random.do a search on random in help and you'll find its now part of
the Math class. Alternatively, have a look in the ActionScript 2.0
Migration section in the Appendix, and you'll find that random()
has been removed in AS3 and Math.random() is now used instead.
Its used a little differently so its a good idea to look it
up. -
Wher can. Fix or buy the back case?
Apple's Limited Warranty http://www.apple.com/legal/warranty/ for iPad excludes coverage for damage resulting from accident, disassembly, unauthorized service and unauthorized modifications.
Apple will provide a replacement iPad for:
iPad model
Out-of-Warranty Service Fee
New iPad
$299
iPad 2, iPad
$249
You can get it repaired at 3rd party repair sources for less $, however, the Apple warranty will be voided. Don't know if there are reapir sources near you. I have not seen any source for DIY repair parts.
iPad Repair & Screen Replacement Services
http://www.ifixyouri.com/16-ipad-repairs
RepairZoom iPad Repair
http://www.repairzoom.com/ipad-repair.html
Mission Repair
http://www.missionrepair.com/Apple_iPad_Repair_Services_s/431.htm
Cheers, Tom -
Returns the integer part of a real number
Hello,
I need to know an integer value as part of a real number, like this:
double a = 0;
double x = 0;
x = 1500.00;
a = (x / 1000);
now "a" must be equal to 1.
Pascal has a function INT (a = INT(x/1000)), and what about java ?
Thanks for help,
guidoHello,
I need to know an integer value as part of a real
number, like this:
double a = 0;
double x = 0;
x = 1500.00;
a = (x / 1000);
now "a" must be equal to 1.
Pascal has a function INT (a = INT(x/1000)), and what
about java ? It is almost the same thing.
double d = 1.5;
int i = (int) d; -
How do I get the missing parts of a song that didn't download fully?
The network connection timed out while I was downloading a song, and now the last minute of the song is missing. Is there any way to get that minute back? I can't re-download the song to my knowledge. I'm not getting much help from Tech Support. Anyone know how to fix this?
I would suggest that you contact iTunes Customer Support.
http://www.apple.com/support/itunes/contact/ -
How to get the Dreamweaver CC interface to floating pallets
ie: no large grouped clunky window, just loose windows you can navigate to desktop easily
Hello ...
Ok i am one of those who hates the gropuped palets, its just to difficult to get to windows underneath, slows work down. I tried pulling all the pallets off the large window but wheni do i still have 1 large app window then when i close closes Dreamweaver ... Really loved the old interface, how do i get back to the "non-winbdows" mac versions of how adobe products windows looked and functioned.
thx
(had to edit - i frogot i did not use 6 as i didnt have time to figure it out then either, just stuck to old version)I believe it's under Edit > Preferences > General where Mac users can turn off the "Application Frame".
PC users are stuck with it no matter what though.
EDIT: Though I'm not sure if it exists anymore, I switched to PC a while back.
Ah, it might be under Window > Uncheck Application Frame -
Want to truncate the integer part of a number
hi gurus
My requirement is round off a decimal value
in such a fashion that
if is 12.7767898 then convert to 12.50
again if it is 12.498989 convert to 12.50.
please help
Thanks in advanceYou could do something like this:
DATA: number(16) TYPE P DECIMALS 4.
whole_part(16) TYPE C,
remainder(4) TYPE C,
value(20) TYPE C.
MOVE number TO value.
SPLIT value AT ',' INTO whole_part remainder.
Then, examine the remainder:
IF remainder(1) GE '5'.
remainder = '5000'.
ELSE.
* do something else
ENDIF.
CONCATENATE whole_part ',' remainder INTO value.
In your data display method, display this character string (value) instead of the numerical value (number).
This is a bit unfortunate because you have to type cast your value to string, but it works well enough. Just make sure you don't have any arithmetical operations on this newly created data field because you will get an exception.
Also, please note that this is not the complete solution, but only to give you an idea.
Regards,
SD -
Getting the first part of a URL
I have a Example URL of -
http://www.red.co.uk/blue/white.html
I need only the following -
http://www.red.co.uk/blue/
That is the URL without the page, but all the directories.
getURL() returns the full URL - http://www.red.co.uk/blue/white.html
getFile() returns - /blue/white.html
getHost() returns - www.red.co.uk
Is there a nice easy way to do this?Try this: 1 import java.net.URL;
2 import java.net.MalformedURLException;
3
4 public class URLTest {
5 public static void main(String[] args) throws MalformedURLException
6 {
7 URL url = new URL("http://www.red.co.uk/blue/white.html");
8 URL newUrl = new URL(url, ".");
9
10 System.out.println(url);
11 System.out.println(newUrl);
12 }
13 }The output is the desiredhttp://www.red.co.uk/blue/white.html
http://www.red.co.uk/blue/ -
Get integer part of a double type value.
double dblVal=150.50;
how will i get the integer part only of variable dblVal?
i want to get the 150 only. please help.
killuasoftWhy would you want to do this? This can overflow your
int for sufficiently large double values, even when
using a long instead of an int.Maybe he previously did a range check or otherwise knows the range of possible values.
Maybe you are looking for
-
I have to Force Quit Mail when shutting down. Is there a fix for this?
-
Spelling box is ticked but still no not working.
I am useing windows 7 and I use hotmail for my emailson my laptop and I found even though I selected to check spelling, it still won't do it and if I need to forward an email, the main body of the email is blank. Now on my other PC which I use window
-
How to clean recent used fonts dropbox on Pages '09?
Hi everyone! I've searched a lot but can't resolve this. I can't clear my recent used fonts on Pages '09. I'm not talking about the box opened with cmd+T, I'm talking about the dropbox next to the font size, bold, italic, etc. I've tried to delete th
-
Should I start with Flash?
I have decided to teach myself how to build and design web pages. I have illustration background, so I have an eye for what looks good. However I am a newbie to web development. I wanted to know if I should start by teaching myself Flash? Or should I
-
IPhoto '08 not recognising a library
Hi I've been using iPhoto '08 for a couple of weeks. I have 2 iPhoto libraries, a 2007 one and a pre-2007 one. iPhoto '08 converted both of them to its new package format the first time I opened them. So far so good; I use the 2007 library on a day-t