Round up a number .
Hi
Can any one tell me how can i round up a number .
for example :
23.80 to 24
23.30 to 23 .
Regards
Rakesh singh
>Joy to the Workbench, the Search is come!
>Let ABAP receive her Guru;
>Let every thread, first search for it,
>And search and search again,
>And search and search again,
>And search and search, and search again.
>
>Joy to the Search, the Round is found!
>Let ABAPers their F1 deploy;
>While fields and tables, functions and methods,
>Round up and down with joy,
>Round up and down with joy,
>Round up, and down, and round with joy.
>
>No more let sins and guests grow,
>Nor spam infest our second home;
>Abuse report buttons, let them flow to mods,
>Far as the curse is found,
>Far as the curse is found,
>Far as, far as, the curse is found.
>
>Still points-hunters come again,
>And make of themselves a pain.
>The repeated answers, go on and on and on,
>Until the thread is locked,
>Until the thread is locked,
>Until, until... the thread... is... locked!
Similar Messages
-
Hi,
I have to manage floats with euro format .
here's the code :
<CODE>
float first = 78.31;
float second = 1.81;
float tot = first + second;
</CODE>
the result of thi addition is tot = 80.11999......
sigh!!
how can i round up this number with 2 digits of precision ?
(tot = 80.12)
thxYou don't. But you can format it rounded. (i.e., the stuff in the java.text package, like DecimalFormat).
Or you can represent the value using ints. (E.g., create a Euro class and have two ints, one for the whole euro value and one for the fractional euro value.
Or you can use java.math.BigDecimal.
This issue keeps coming up. Check the forum for a recent thread about fractions. -
May I know how to round a double number to 2 decimal points?
if I have a double number 135.25689951591, how can I round this number to make it output as 135.26?
double number = 135.25689951591;
java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");
System.out.println(df.format(number));Alll this will do is display the value 135.26, number will still hold 135.25689951591 -
I have a field where the final answer comes up as a decimal and the client wants the final answer for the employee to see to be a whole number, but he wants it rounded up, no matter what the decimal answer is. Is there a way to do that?
The script could be something like:
// Custom calculation script
(function () {
// Get the field values, as numbers
var v1 = +getField("Average of scores").value;
var v2 = +getField("Text 4").value;
// Perform the calculation, round up to nearest integer, and set this field value
event.value = Math.ceil(v1 * v2);
For more information on the Math.ceil method, see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/ceil -
Need help with rounding up a number
In my codes, there is a loop and when I cfdump the value, it
looks like this:
2.0,.3.0,4.0, all the way to 32.0, etc
I need to use these number in a For Loop from="1"
to="#ThisNumber#" but first I need to round it up so ThisNumber
will come out as a whole number and not with the dot zero
Is there a function in CF that can do this? Please help!alecken wrote:
> In my codes, there is a loop and when I cfdump the
value, it looks like this:
> 2.0,.3.0,4.0, all the way to 32.0, etc
> I need to use these number in a For Loop from="1"
to="#ThisNumber#" but first
> I need to round it up so ThisNumber will come out as a
whole number and not
> with the dot zero
> Is there a function in CF that can do this? Please help!
>
A quick glance at the documentation for mathmetical functions
turns up
int(), floor() and ceiling() depending on how you would like
to round
different types of numbers. -
Formula for rounding down a number in a Pages WP table cell
Could someone advise me on a formula? I know the answer might be straight-forward, but am not used to needing anything other than very elementary formulae, and cannot find a list in the Pages Help guide.
I have a Pages WP document which contains a simple table. One cell is the sum of 4 others divided by 4, and is set to show 2 decimal points, e.g. 7.35, 6.75 etc. (This number is never above 9.00).
I need this sum to always round down to the nearest .5 or .0, i.e. 7.35 would round down to 7.00, and 6.75 would round down to 6.50. (Simply limiting the decimal point to 1 doesn’t do it, because 6.75 would round up to 6.8).
Any help much appreciated,
Graham FalveyI would try with
=ROUND(B*2,0)/2
but I'm not sure that you really want that 5.25 returns 5.5
Explanations about this kind of problem which are the same in Keynote, Numbers and Pages are available in the Numbers Guide.
Yvan KOENIG (VALLAURIS, France) mercredi 2 septembre 2009 20:55:36 -
Rounding off to nearest whole number without condition
hi,
i want to round a real number to an integer value,,wihout any conditions like
10.01 should be 11
10.1 should be 11 and like that
is it posible to do it?
thanks in advance.
amitIt doesn't look like you are trying to round to the nearest whole number here. It looks like you are trying to find the smallest integer value that is greater than or equal to the real number. If so, you would want to use the CEIL function (i.e.
1 SELECT CEIL(10.01)
2* FROM dual
SCOTT @ hp92 Local> /
CEIL(10.01)
11Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Is there anyway you can create a calculation to only round a number up and not down?
You can use Math.ceil() to round up a number in JavaScript.
-
Round decimal number to two places
trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.
-tried using math.round but it only rounds to nearest integer
-tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to double
*is there a round method that allows you to specify decimal places?
*or is there an easy method to cast a string back to a double?
any advice is appreciated:)coynerm wrote:
trying to round a decimal number to two places i.e. 1.98999 should round to 1.99.Agree.
-tried using math.round but it only rounds to nearest integerI advise against rounding in most newbie situations. Usually it's the display of the variable you want to change.
-tried using decimalformat class but that converts to string, and cast wont allow me to convert from string back to doubleOf course cast won't allow you to convert back. If you wanted to do that you'd use Double.parseDouble(stringVar); But we don't know why you are doing all this converting in the first place.
*is there a round method that allows you to specify decimal places?
*or is there an easy method to cast a string back to a double?Advice: Forgetting all this fooha with rounding, what in essence are you trying to achieve? Why all of this number manipulation in the first place? It will affect what should be the best answer. -
how can I determine whether the number of digits after decimal point is greater than one? For e.g., the float number of 16.04(or more digits) should be rounded, but the number of 16.1 should not be rounded.
Is there any other convenience method except the split method in String class?
thanks in advance.Yes, the formula you mentioned is what I'm using to round the float number to the tenth place.
float f = ...;
f = Math.floor(f*10) / 10;
but the float number I'm choosing to be rounded should have the number of digit numbers after decimal point greater than one, for e.g.,
f = 16.045 need to be rounded to 16.0 using that formula
f = 16.01 ......
f = 16.0 need not to be rounded since it aready just have one digit number after decimal point
f = 15.9 ......
sorry about the confusion. thanks for your help. -
I have field that I (round(total,1)) round to 1 decimal place (102.2), but it doesn't round if it is a whole number (100.0). Does anyone know how I can round a whole number to one decimal place (with a .0).
Thanks in advance.
~Vannette
nullI understand how to do this in Reports... but I used the round function at the data level of the report (PL/SQL). Is there a way to do this at the data level?
Thanks.
~Vannette -
Rounding a number upto two decimal places.
Hey !
My question is regarding the rounding of a number in such a way that answer that we get after the rouning comes upto two decimal places,no matter how small or the large the number before rounding was.
Somebody please help me.
thankshi,
use BigDecimal class in java.math package.
here is some code how to do it ..
BigDecimal bd = new BigDecimal(your number here);
bd.setScale(2,BigDecimal.ROUND_DOWN)
System.out.println(bd);
hope this helps ...
bye
ashok -
Hi,
How can i round up float number to two decimal number.
For example
Number is 45.987654532 then It should be rounded up to 45.98
Number is 45.987654546 then It should be rounded up to 45.99Appriciated sample souuce (If any)
Tanks in advanceYou could have a look at String's format() method. The format strings are
described in detail here:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.htmlpublic class Round {
public static void main(String[] args) {
double number = 45.987654546;
String roundStr = String.format("%.2f", number);
// Rounded is 45.99
System.out.println("Rounded is " + roundStr);
// The same thing
System.out.printf("Rounded is %.2f%n", number);
}Note: these methods generate rounded Strings from floating
point numbers. Also, they round to a string representing the "nearest"
number - your first example is a little hard to understand in this regard. -
Sample java program to round bigdecimal number to its nearest number
hi,
i want to round a BigDecimal number to its nearest number
eg. if my calculation result is 75.3 then it has to be rounded to 75
if my calculation result is 75.6 then it has to be rounded to 76
if my calculation result is 75.5 then it has to be rounded to 76
can anyone help me out resolving this
thanks in advancepublic class MyBigDecimal {
public static void main(String [] args){
double d = 75.3;
System.out.println("d = " +d + ", " + Math.round(d));
d= 75.6;
System.out.println("d = " +d + ", " + Math.round(d));
d=75.5;
System.out.println("d = " +d + ", " + Math.round(d));
d=75.99;
System.out.println("d = " +d + ", " + Math.round(d));
}What's the output? -
Chnfind unable to find the decimal type by variable and sometimes "Round" command
Dear all,
During the work with Diadem I got two troubles. Could you please take a look and show me the wrong if you find the issue?
1.) Here is my trouble as we see the photo below. It is most important problem which I have. I really have no idea why it could happened. It is alway happened to find a value with decimal type's variable, and even that variable is changed to "str()".
setlocale("en-gb")
dim Min_point,Index_low,result
Min_point=val(Data.Root.ChannelGroups(1).Channels("CopyYangle").Properties("minimum").Value)
Min_point=round(Min_point,6)
Min_point=str(Min_point)
msgbox("The Min.Value is: "&Min_point)
Index_low=Chnfind("ch(""CopyYangle"")<="&Min_point&"", 1)
msgbox("Index No. of Min. Value is: "&Index_low)
Index_low=Chnfind("ch(""CopyYangle"")<=-0.11374 ", 1)
msgbox("Index No. of Min. Value is: "&Index_low)
2.) Still the problem with ChnFind() or ChnFindreverse(). If I change the Rounds off a number to the nearest integer with the function "Round()" it might not work in ChnFindreverse(). Such like it works under 4, 6, 8 and even 7 but doesn't work with 3 and 5. Is this logical?
setlocale("en-gb")
Dim XE, Xchannel, Ychannel,round_N0
Xchannel = "[2]/Right"
T1 = Xchannel
R1 =val(Data.Root.ChannelGroups(2).Channels("Right").Properties("maximum").Value)
round_N0=4 ' <========= 3 and 5 Not work, 4, 6, 7, 8 .... work
R1 =round(R1,round_N0) ' <=========
msgbox("Max. point is: " &R1 &VbCrlf& "Round Nr is: "&round_N0)
L1 = ChnFindReverse ("Ch(T1)>=R1",0)
msgbox("Index number for Max.Point is: "&L1 &VbCrlf& "Round Nr is: "&round_N0)
.tdx is a valid extensions for an attachement?
If you couldn't open the TMD file. Please remove ".tdv" the attacments file name to make sure it is "ChnFind.tdx" but not "ChnFind.tdx.tdv".
Kind regards / Mit freundlichen Grüßen
J.Huang
Attachments:
ChnFind.TDM 5 KB
ChnFind.tdx.tdv 39 KBHello J.Huang,
I downloaded the files and was able to get it to work. It looks like when you format the minimum value to a string, you loose precision and then ChnFind doesn't find the value your are looking for. He is an example which worked for me :
Set oChnY = Data.Root.ChannelGroups(2).Channels("Right")
sgValue = str(oChnY.Properties("minimum").Value,"d.ddddddddddddddd")
Index = ChnFindReverse("Y<="&sgValue,,Array("Y"),Array(oChnY))
LogFileWrite(Index)
Using symbols (parameters 3 and 4) is not necessary to get the solution. The key is teh second value for "str" which formats using more digits. As soon as you reduce the number of digits, you may no longer get a result.
Ther is an alternative to ChnFind, in case there is only one occurance in teh signal which has the minimum value
Set oChnY = Data.Root.ChannelGroups(2).Channels("Right")
Index = PNo(oChnY,oChnY.Properties("minimum").Value)
LogFileWrite(Index)
I hope one of the two options works for you. I tested the approach with teh first channel too and it worked as well
Maybe you are looking for
-
Adobe Media Encoder P2 File Size Too Big for Fat32
Hi everyone, I'm working on a project that has to be delivered on an actual P2 card. I'm on a Mac running 10.9.1 using Media Encoder 7.2.2.29. My final files are ProRes files and I dropped them into Media Encoder and selected the P2 AVC-Intra 100 108
-
Will Windows 7 domain policies work with new Windows 8 workstations?
Dear all, We have five number of Windows 7 processional workstations in our Organization. Now company decided to replace these workstations to windows 8 professional. My questions is these five new windows 8 workstations are in work group. I will ad
-
Schema owner with DDL privileges only
Hi, Oracle 11.2.0.2 What is the easiest way of creating a schema owner that can own all the schema objects (tables, viws, procedures etc) WITHOUT being able to see the data in tables. In short can do DDL without being able to DQ or DML. Thanks
-
Interactive Reporting - Is there a way to include user defined js file?
Hi, My struggle with Hyperion IR 11.1 Studio continues... This time I need to know if it is possible to put my own js file somwhere in Studio and make it visible to all my code inside Studio. I have some function ('classes') defined which I use exten
-
Qustion for wireless card Satelite Pro M30
Hello, I laptop has the Intel 2100. Would a 2200 Intel card purchased from the open market operate, or must I purchase the Toshiba one? Thanks and Regards George