Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can I build "my own type of java number"?

  1. #1
    Junior Member
    Join Date
    Mar 2022
    Posts
    15
    My Mood
    Sleepy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Can I build "my own type of java number"?

    Hi,
    My question is whether I can create my own number type in Java or not? For instance, there exists max and min limits for integer,long,double and float built-in types. But,I want to add two 50 digit numbers. To do this, can I create my own number type and add them using "+"(plus/add) java operator?

    Actually I am using a linux program galculator which can do that : 9999999999999999999999999999999999445+666666666666 666666666666666666 = 1,00000006667e+37

    Doing such mathematics calculations is important for calculator applications. Just to clarify that I do not need to code which adds two 50 digit number, that is out of my question, that is just for giving an example why I need to create such a custom type.


    Any guide is appreciated. Thanks.
    Last edited by grogger; March 23rd, 2022 at 05:06 AM. Reason: solved

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,892
    Thanks
    58
    Thanked 2,692 Times in 2,642 Posts

    Default Re: Can I build "my own type of java number"?

    There is the BigDecimal class that will hold large numbers.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    grogger (March 23rd, 2022)

  4. #3
    Junior Member
    Join Date
    Mar 2022
    Posts
    15
    My Mood
    Sleepy
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: Can I build "my own type of java number"?

    Quote Originally Posted by Norm View Post
    There is the BigDecimal class that will hold large numbers.
    Ok.

Similar Threads

  1. Replies: 1
    Last Post: August 20th, 2019, 07:07 AM
  2. Replies: 4
    Last Post: July 18th, 2014, 02:04 AM
  3. Replies: 1
    Last Post: July 16th, 2014, 04:16 AM
  4. Replies: 2
    Last Post: May 22nd, 2014, 01:17 PM
  5. Replies: 2
    Last Post: June 22nd, 2013, 10:30 AM

Tags for this Thread