Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:39:07+00:00 2026-06-17T07:39:07+00:00

Languages like Java , c++ , c , c# allow integral type or an

  • 0

Languages like Java,c++,c,c# allow integral type or an expression that evaluates to an integral type in switch-case statements.[string literals and some other types are allowed in some languages]

Why do we need to use only integral types or some limited number of types and not types like double,float?Is it because of some kind of optimization or just for simplicity?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:39:09+00:00Added an answer on June 17, 2026 at 7:39 am

    Firstly, Java 7 allows switching on String values … and so does C#. (And in Java, you can’t switch on a long … thanks for reminding me Peter.)

    However, the reason that switching on float and double is not allowed is most likely that the insidious effects of rounding errors and imprecise representations of floating point numbers would make code that uses floating point switches very error prone … or require a special syntax for expressing error bounds in the case values.

    Now if there were lots of good use-cases for switching on floating point values, then one would expect that some language would support this. But to my knowledge no mainstream has programming language ever gone down this route.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that more-dynamic-than-Java languages, like Python and Ruby, often allow you to place
I know that (at least for some JIT-ed languages like Java) that declaring member
With generics on languages like C# or Java, you can have a factory that
Why don't we see C-like languages that allow for callables with polymorphism in the
I am very new to symfony. In other languages like java and others I
I moved one years ago from classic OO languages such like Java to JavaScript.
When I read about the performance of JITted languages like C# or Java, authors
Possible Duplicate: Should C++ eliminate header files? In languages like C# and Java there
I've seen a few neat features in other languages around Java like generators and
Is the nesting of functions possible in the object oriented languages like C#, Java,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.