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.
Similar Messages
-
I have two companies sending me indesign documents. One opens up and the dictionary is set to English. The other file opens at is in Hebrew, Not sure how to fix the Hebrew part and whether or not the fault lies at my end or at the other end
If only the language is Hebrew, you should correct it in the Paragraph and Character Styles.
But in such a case I would expect more problems.
If you are a creative cloud subscriber you should additionally install the InDesign version, English with Hebrew support:
Go to the preferences of you CC.app. It is found behind the Gear Symbols on the top right.
When the preferences open, go to the Apps section.
Change the App Language to English with Hebrew support.
Now you can install it. It will install on the very same place where your InDesign program is found some additional plugins, which will give you access to Hebrew functionality, like RTL text. Otherwise you will inherit in the document (and where you copy and paste it from such a document into another one). But now you can change or repair problems.
Now repeatstep 1 + 2, but you need not to install your own language again. InDesign will now, when started, run in the language of your OS (when you have it installed in that language) but with more functionality to handle problems with Hebrew documents.
The same steps you would have to do with Arabic or Asian documents. These languages will also add more plugins. But keep it limitted to those language you need. I have installed it that way, because I get sometime documen where the text flows the wrong direction or the numbers come up in Farsi digit, not in Arabic digits. For such purposes I need versions in languages I don’t understand myself. -
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. -
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; -
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 -
Fixed point division on FPGA doesn't show the fraction part
Hi,
I'm trying to normalize a fixed-point complex vector. My problem is in the part of fixed point division. Assuming I am dividing x by y (x/y), then I multiply first x by 2^26 and y by 2^9 then divide both of them using high throughput function then multiply the result by 2^-17 and here the problem appears. The result is zero, and the fraction part doesn't appear. My question is: does the "scale by power of 2" block discards the fraction part and only keeps the integer part, even if the input is a fixed point input with fraction part of 20 bits length? If so then how can I get the result of dividing a number by a bigger one? I mnean how can I display a result < 1? If not, then why isn't the fraction part displayed? The numbers I used as an example are: x=10, y=182.
The indicator is adjusted to have 64 bit word length and 44 integer length. I also write this data into a memory element and then read it through a FIFO to transfer it to the RT vi. Both of the memory and the FIFO are configured with the same word and integer lengths above. I am using 7965R series FPGA.
Thanks in advance.It's worth noting that I tried this same procedure on RT vi itself and the fraction part was displayed.
-
Hi everybody,
I'm a brand new user of Labview (v 2009). I try to save some data from my electrometer (Keithley 617) in an array (time and electric current). And it works, I can see these data in a text file, with the time on the left, and on the right the value of the current. The issue is that I can only record the integer part. The current I try to record is something like 10E-12 A. So if I don't multiply the result by a constant of 10E15 for example, the result would be 0 instead of 0.00...004658 A. And it is the same for the time. I can see 1, 1, 1, 2, 2, 3, 3 instead of 1.034, 1.45, 1.89, 2.36, 2.98, 3.48, 3.95 for example. I've try to change the format, but it doesn't solve this problem of the integer part. I'd like to see the whole number (integer and decimal parts). Attached, please find my program. Also I attached 2 files. test01 is what I'd like to record, and test02 is what I currently record. Could you help me please ?
Thank you !
PS : I try to expose as best as I can my problem, I'm French...
Solved!
Go to Solution.
Attachments:
Keithley 617a Yang.vi 27 KB
test01.txt 3 KB
test02.txt 1 KBOk I think I found a solution. A double precision float "DBL" was missing just before the "measurement" part. I attach you my program and the results.
Thank you for your help !!
Thomas.
Attachments:
Keithley 617b Yang.vi 26 KB
test02.txt 1 KB -
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. -
How to fix the decimal part(round) i.e. fix the size of float.
how to fix the decimal part(round) i.e. fix the size of float.
You can use BigDecimal to round of your number.
float f = 5.678f;
f = new BigDecimal(f).setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();If you just want to display the float with a certain number of decimals, you can use java.text.DecimalFormat
DecimalFormat df = new DecumalFormat("0.00"); // two decimals
float f = 5.678f;
System.out.println(df.format(f)); // should show up as 5.68 -
my ant video player after i updated to firefox four is now in the upper part of the screen where it opens up and i cant find out how to fix it
Create a new profile as a test to check if your current profile is causing the problems.
See "Basic Troubleshooting: Make a new profile":
*https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
If that new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
See:
*http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox -
I have an iPod 4th gen and the bottom part of it doesn't work where the space, .?123, and the go buttons are not working I droped it yesterday but it started doing this an hour ago I can slide to get in but it's stops working after that someone tell me how I fix this
Try:
- Reset the iOS device. Nothing will be lost
Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Restore from backup. See:
iOS: How to back up
- Restore to factory settings/new iOS device.
If still problem, make an appointment at the Genius Bar of an Apple store since it appears you have a hardware problem.
Apple Retail Store - Genius Bar -
I recently cracked the bottom part of my iPhone 5 right by the home button, would it be beneficial to put a screen protector over the cracks so it won't break anymore? I've cracked it twice now and can't afford to fix it again
How did you crack the screen using a Lifeproof case??
http://www.otterbox.com/defender-series/defender-series,default,pg.html -
The bottom part of the screen is like bright it looks all weird i cant see annything in that part my ipod still has the 1 year warranty do u guys think i can get it fix for free or would i have to pay?
Try the following:
- A reset. Nothing is lost
Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
least ten seconds, until the Apple logo appears.
- Restore from backup
- Restore to factory settings/new iPod.
If you still have the problem that indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order. If you iPod is defective, within warranty and not abused, Apple will exchange it at no cost. -
The bottom part of my iphone4 screen cannot tap.. I restored it 2 times with the latest firmware and yet still the same..is it possible to fix this?how? please guys help me =(
iPhone and iPod Touch: Troubleshooting touchscreen response: http://support.apple.com/kb/TS1827
-
I have the first part of a song on my iphone, the second part of the same song shows up in my "purchased" list in itunes store. It used to play the whole song on my phone, what happened and how can I fix this? thanks.
Not if you sync your contact to itunes using the program provide i.e outlook..etc
Maybe you are looking for
-
My daughters ipod 5 is noticeably quieter than my 5s.. Is this normal or is there something wrong with it? It seems very quiet for something that is made to play music. Thanks!
-
Hi all! I'm having a hard time with addresses at Sapscript and Smartforms: for some reason, some customer's addresses apear with the folowing format: <TITLE><NAME> <ADDRESS> <POST CODE> <LAND> Why does the NAME apear in the same lina as TITLE does? C
-
Nested Loop and Driving Table.
In the documentation I read these (/B19306_01/server.102/b14211/optimops.htm#i82080). The optimizer uses nested loop joins when joining small number of rows, with a good driving condition between the two tables. You drive from the outer loop to the i
-
Keyboard special keys not working
I have an older imac (imac4.1?) with a new 2009 wireless keyboard and none of the special function keys work aka the volume keys eject and so on I have done everything I can think of it has OS X 10.6.2 snow leopard and they did not work with my older
-
Hi, Oracle9iDS has a report server, and Oracle9iAS also a Reports Server. My understanding is that Oracle9iDS is a development environment, and the report services are not meant to be used in production environment. Can anybody refer me to some docs