We help IT Professionals succeed at work.

How can i create a new data type ?

bcp5190
bcp5190 asked
on
How can i create a new data type like doubledouble and use it in my java application.

i want to create a new data type where i can hold (largest number of double)**2
Comment
Watch Question

Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
You need to create a new class a define all the methods you require:

public class DoubleDouble
{
  ...
}

Author

Commented:
but how can i create a new data type which can hold 2**128 value. i think largest value for double is 2**64 but i want to hold 2**128

is there any way i can create a new data type like doubledouble(128 bit size)
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Java does not support creating new data types.
The only way you can do what you require is by using a class.

Have a look at the BigDecimal class. Sounds like it is what you are looking for.
yes u can make the class having the string member but u will have to use the operator overloading in that case. and u will have to study operator overloading in java.
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> operator overloading in java

Do tell me more?

Author

Commented:
i think u are right but how can i create a instance of bigdecimal class and display the square of maximum value of a double.
Jim CakalicSenior Engineer

Commented:
How about:

    BigDecimal bd = new BigDecimal(Double.MAX_VALUE);
    bd = bd.multiply(bd);
    System.out.println(bd.toString());

Jim
bcp5190,

Some of these questions have been open for some time, and our records show you logged in as recently as Jan 23, 2002. Please resolve them appropriately as soon as possible.

http://www.experts-exchange.com/jsp/qShow.jsp?ta=osgen&qid=20250789
http://www.experts-exchange.com/jsp/qShow.jsp?ta=win2k&qid=20224108
http://www.experts-exchange.com/jsp/qShow.jsp?ta=win2k&qid=20224027
http://www.experts-exchange.com/jsp/qShow.jsp?ta=win2k&qid=20218730
http://www.experts-exchange.com/jsp/qShow.jsp?ta=msoffice&qid=20249772
http://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20255121
http://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20250781
http://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20248828
http://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20247239
http://www.experts-exchange.com/jsp/qShow.jsp?ta=mssql&qid=20244374
http://www.experts-exchange.com/jsp/qShow.jsp?ta=java&qid=20189160
http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20241876
http://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=20187022
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20249686
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20248047
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20246855
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20246318
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20244409
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20242375
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20093765
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20249476
http://www.experts-exchange.com/jsp/qShow.jsp?ta=asp&qid=20158800
http://www.experts-exchange.com/jsp/qShow.jsp?ta=html&qid=20235587
http://www.experts-exchange.com/jsp/qShow.jsp?ta=iis&qid=20186130

Thanks,

Netminder
Community Support Moderator
Experts Exchange
There has been no activity in this question in quite some time, and it looks like it has been abandoned. As part of our ongoing mission to clean up the topic areas, a Moderator will finalize this question within the next seven (7) days. At that time, either I or one of the other Moderators will force/accept the comment of jim_cakalic.

DO NOT ACCEPT THIS COMMENT AS AN ANSWER. If you have further comments on this question or the recommendation, please leave them here.

Netminder
Community Support Moderator
Experts Exchange
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Out of curiosity, why jim's comment?
objects,

Only because the questioner seemed to suggest to me that the others weren't satisfactory. I'm certainly open to suggestion -- at least I finally got a response from SOMEONE... <grin>

Netminder
Community Support Moderator
Experts Exchange
Jim CakalicSenior Engineer

Commented:
Netminder, since objects did first _suggest_ the use of BigDecimal, I would have no problem with the points being awarded to him. My post was primarly to demonstrate usage.

Jim
Jim,

Thanks for responding; if I have no response from bcp5190 by the 10th, I will accept the comment of objects.

Netminder
Jim CakalicSenior Engineer

Commented:
Excellent. Thanks for support. I've noticed much more attention lately by yourself and Moondancer. It is really appreciated.

Jim
Thanks for the kind words; I'll pass them along to Moondancer.

Netminder
:)
Thanks, Jim and Netminder.  Smiles feel great.
Moondancer
Community Support Moderator @ Experts Exchange
Force/accepted by

Netminder
Community Support Moderator
Experts Exchange

Explore More ContentExplore courses, solutions, and other research materials related to this topic.