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

  • SEARCH
  • Home
  • 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 6820811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:28:09+00:00 2026-05-26T21:28:09+00:00

Currently I’m using TCC as it’s the easiest thing to get setup on windows.

  • 0

Currently I’m using TCC as it’s the easiest thing to get setup on windows. Simply unzip and you’re ready to go. However I’m open to other compilers, GCC, whatever microsoft has on offer etc.

My problem is that I need to validate the input to a size 16 array of integers. Here are my rules:

if number is under 15 (including negative values) then input is valid
if number is under -2147483648 then -2147483648

if number is over 2147483647 then 15
else if number is over 15 then mod 16

if the number is a decimal, remove decimal point and validate again

Considering I’m using C, the last point scares me, and I’ll come back to it later. For now I’m just trying to handle the first 4 conditions.

The problem I’m running into is that trying to test for the outer bounds results in Integer overflows and screws up my checks. So I’ve made a temporary array of long longs to hold the input for validation purposes. The moment everything is successfully validated it should fit in an array of Integers, so I will (somehow) copy the long longs from the temp array to the actual one and start the program as normal.

I’ve messed around with long longs and trying to do what I want to do, but my code is getting messy fast and everything is so vague and machine dependant in C so when something goes wrong I don’t know whether it’s me and my crappy coding, or the fact that my machine is different to everyone else’s that is causing the error. I am going to stick at it cause I know this sort of thing can be investigated and worked out, however I don’t want to waste too much time on it so I’ll ask SO and see if there’s a shortcut.

The decimal validation part I’ve got various ideas on how to approach, but I’m not hopeful. What’s your opinion?

Anyone who wants to know why I’m doing this: It doesn’t matter, I can solve the higher level problem that requires this array quite easily and it will work for all valid inputs. However I’m just being pedantic right now, hence this question.

  • 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-05-26T21:28:10+00:00Added an answer on May 26, 2026 at 9:28 pm

    First, your conditions have some problems. If a number is under -2147483648, it’s also under 15, so that check never matches (neither being a decimal for numbers under 15).

    Second, you can check for overflows with strtol (check errno for ERANGE) and then compare with your limits (though there’s no need if your long has 32-bits and is in two’s complement).

    As for decimals, if you always want to remove the decimal point (not what you’re saying you want because you condition that on a series of other conditions failing), you can setup a preprocessing step that removes periods from the string. It can easily be done in-place with two pointers – a read pointer and a write pointer.

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

Sidebar

Related Questions

Currently we have a hybrid ASP/PHP setup connecting to a SQL Server 2005 database.
Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently i'm having trouble using two functions in my -(void)viewDidLoad , both of these
Currently we use log4net of version 1.2.10.0 and we should start using some 3rd
Currently we are using Trac . Tickets are good for tracking tasks and related
Currently It just opens up the xml, but i want to get a dialog
Currently I’m trying to get the hang of a block copy with my current
Currently unable to get my rss feed to validate through W3C RSS Validator .
Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently, my ListViews look like this: How can I achieve that Windows 7 native

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.