What programming languages use the function round0() to truncate a number to an integer?

I'm trying to change some code to round to the nearest integer instead of the lowest integer. round() crashed the program, and I don't know what language it was initially written in to be able to identify a function that would work for rounding to the nearest value.

5 Answers

Relevance
  • roger
    Lv 7
    4 years ago
    Favorite Answer

    the usual way is to add 0.5 and convert to integer.

  • Ken
    Lv 4
    4 years ago

    Well round in many languages allows a specification of the rounding level (number of decimal places). Rounding is normally to the nearest value, i.e. round 5.46 to next integer would be 5. If you always want to round down try a truncation function.

  • ?
    Lv 5
    4 years ago

    What language are you working in?

    The quick and dirty way to round in languages like C is to add 0.5 and then do the type cast, with truncation.

    Would something like that work for you?

  • cpcii
    Lv 7
    4 years ago

    There are many languages that do it. We would need to see more code to determine it. What are the first couple lines of the program?

    I know that Javascript does it (not a compiled language), VB.net And I think C# also do it, and I wouldn't be surprised if C++ does it also or Java.

    What are you using to compile it in? That will give you the best answer what language its in.

  • How do you think about the answers? You can sign in to vote the answer.
  • Anonymous
    4 years ago

    well you can try cint(5.54) in vb.net which will round to an integer, or just math.round(5.54). To round to the nearest tenth use math.round(5.54,1) which would give you 5.5... To always round down to the nearest whole number use math.floor(5.54) which would give 5 and to round up use math.ceiling(5.54) which would give 6.

Still have questions? Get your answers by asking now.