[Solved] Stop Base from rounding decimals

Creating tables and queries
Post Reply
Fallynn
Posts: 9
Joined: Sun Oct 22, 2017 10:42 pm

[Solved] Stop Base from rounding decimals

Post by Fallynn »

I'm trying to import a large amount of data from a spreadsheet. They are numbers ranging from whole numbers to as many as four places after the decimal. The whole numbers are fine but the decimals get rounded to the nearest whole number. I've made sure the field type is “decimal”. I've tried changing it after the fact and it lets me leave the field box to move to the right but the moment I move up or down, it rounds it off again. I've checked to see if it's just being displayed as rounded but is stored correctly and as best as I can determine, it's being rounded upon import. Any advice would be appreciated.
Last edited by RoryOF on Mon Oct 23, 2017 3:17 pm, edited 3 times in total.
Reason: Added green tick [RoryOF, Moderator]
OpenOffice 4.1.3 on Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Stop Base from rounding decimals

Post by keme »

AFAIK the "decimal" data type is fixed-point, so you need to specify the maximum number of decimals you want to have. If you leave that at the default of zero, you can only have integers.

Data types real, float and double are floating point, which is usually easier to work with.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
Fallynn
Posts: 9
Joined: Sun Oct 22, 2017 10:42 pm

Re: Stop Base from rounding decimals

Post by Fallynn »

That worked for some of the numbers but not others. The ones giving me problems are frequencies. Some of my higher frequencies can be something like 1234.1234
Since you brought it to my attention that I was using the wrong number type (Thanks BTW :) ) I've just tried creating a test table with all the different types.
Depending on which one I use, I can get 4 places either before or after the decimal but never both unless I use a text box; which I can do and I suppose I will but I wondered if there was a better way.
OpenOffice 4.1.3 on Windows 10
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Stop Base from rounding decimals

Post by keme »

If you work with a database embedded in the Base file, you could perhaps attach that file to a post here so we can have a look at it.

If there is content you would rather not reveal to the general public, just make a copy of your file and remove all tables except that test table you mentioned.
Fallynn
Posts: 9
Joined: Sun Oct 22, 2017 10:42 pm

Re: Stop Base from rounding decimals

Post by Fallynn »

Once again you've pointed me in the right direction. :D I created a test database to post here and when I did, I went right back to not being able to see anything past 1 decimal place even though at least some of them worked fine in my real database. At that point I figured it had to be due to how it was been shown, not stored. So I checked the column format and sure enough, it was only showing one place after the decimal.
After that, it was easy to figure out the rest.

So problem solved. Real and Double were the types that do what I need. Thanks for the help. :D
OpenOffice 4.1.3 on Windows 10
Post Reply