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 7739757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:36:06+00:00 2026-06-01T08:36:06+00:00

I have a database storing VIN numbers (stored as VID) for vehicles which are

  • 0

I have a database storing VIN numbers (stored as VID) for vehicles which are 17 characters in length. I am trying to increment to the next VID to display it on the page where a new vehicle can be added in the database. The VID field in the database is type bigint(17) and has auto_increment set.

$incr_query = "SELECT MAX(VID) FROM Vehicle";
$incr_result = mysql_query($incr_query);
$row = mysql_fetch_assoc($incr_result);
$vid = $row["MAX(VID)"] + 1;

Output:

print var_dump{$row);//array(1) { ["MAX(VID)"]=> string(17) "12345678123456788" }
print gettype($vid);    //double
print $vid;             //1.2345678123457E+16
print number_format(++$vid, 0, '.', '');       //12345678123456788
print number_format(--$vid, 0, '.', '');       //12345678123456788
print number_format($vid - 5, 0, '.', '');     //12345678123456784 

I’m not sure what’s going on here. According to the PHP float manual:

"The size of a float is platform-dependent, although a maximum of ~1.8e308 with 
a precision of roughly 14 decimal digits is a common value"

EDIT:

So using bcadd, these are the outputs:

$vid = bcadd($vid, '1', 0); 
print "\n".$vid;                              //12345678123456789
print "\n".number_format($vid, 0, '.', '');   //12345678123456788
  • 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-01T08:36:08+00:00Added an answer on June 1, 2026 at 8:36 am

    The VID number might look like a “double” or “integer” or whatever but it isn’t. Store it as string. Check out Skeet on Vimeo for an explanation. It starts around 6:10 and ends at, around, 10:00.

    A bigint in the DB might do, but a double is a floating point and floating points are not intended to be used as discrete numbers; that’s why they’re floating points. I would go with string (varchar) all the way, up to the database. Using a bigint would encourage you/other developers to keep treating it as a “number” wich, in fact, it isn’t (exactly).

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

Sidebar

Related Questions

I have a database storing wiki formatted text which I would like to display
I have a Database storing details of products which are taken from many sites,
i have a mysql database storing uploaded photos , i am trying to generate
I have a database storing multiple columns and I am trying to create efficient
I have a database table which storing shop list for users. I wish to
We have a sharepoint based application that uses a custom database for storing metadata/files
I'm doing a database for storing my eBook collection. Most of them have the
We have been storing our staging database on the production database server with the
I have an SQL Server 2008 database with a column of type geography storing
I need to manage hierarchy data storing in my database. But I have a

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.