Re: Save high numbers without exponent(example: 12345678925678453 instead of 1.23456789256785e+16 )

22 views
Skip to first unread message

gabor

unread,
Jul 11, 2012, 3:01:56 PM7/11/12
to redbe...@googlegroups.com
Yes you can use a cast

http://www.redbeanphp.com/extra/meta_data


cast.string will work.

On Wednesday, July 11, 2012 4:21:08 PM UTC+2, Arne Zelasko wrote:
Hi

I want to save numbers with 17digits in my database. unfortunately redbean saves a high number like 12345678925678453 as a number with an exponent like this 1.23456789256785e+16. how can i save such a number without an exponent.

 is it possible to save an number as a string ?

Jake Chapa

unread,
Jul 11, 2012, 3:08:46 PM7/11/12
to redbe...@googlegroups.com
Will casting it to a string change the data type in the database? Or will the db remain a float?

--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To view this discussion on the web visit https://groups.google.com/d/msg/redbeanorm/-/ND1HsWhEhfQJ.
To post to this group, send email to redbe...@googlegroups.com.
To unsubscribe from this group, send email to redbeanorm+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/redbeanorm?hl=en.

David Hawley

unread,
Jul 11, 2012, 6:47:06 PM7/11/12
to redbe...@googlegroups.com
IEEE double precision floating point http://en.wikipedia.org/wiki/Double-precision_floating-point_format, stores 53 bits of precision (or about 16 decimal digits). If you really have 17 significant digits, then a float will truncate 1 or more of your digits. You should look into using either a bigint (64 bits) or a string in your db.

gabor

unread,
Jul 12, 2012, 3:09:22 AM7/12/12
to redbe...@googlegroups.com

Yes, a cast will affect the column type.

Reply all
Reply to author
Forward
0 new messages