** Combining replies **

Mike-

The reality is computers are limited in how to express these types of 
numbers. I do agree that keeping the a / b as separate fields is a sound 
approach that allows you to maintain precision, and allows you to decide 
when to take the rounding hit.

As Evgenij mentioned, you can store the fields as 2 separate columns, and 
have the functions operate on those columns.

For example:

create table T {
a BIGINT // or DECIMAL, DOUBLE, etc
b BIGINT // or DECIMAL, DOUBLE, etc
}

select * from T // displays the a, b column values

Create a few helper functions:
AB_INSERT (8765309, 90210) // inserts values into the a / b columns and 
abstracts how it is stored on the backend -- for example, if you need to 
change the backend at some point
AB_AS_DECIMAL (a, b) // perform a / b calculation
AB_AS_BIGINT (a, b) // perform a / b calculation
AB_AS_NUMERIC (a, b) // perform a / b calculation

-Matt

On Friday, August 7, 2020 at 10:43:54 AM UTC-5, Mike Goodwin wrote:
>
> Thanks Matt,
>
> Yeah, I know this is possible, but obviously it's pretty cumbersome, and 
> if you do something as simple as SELECT * FROM T, you will not get to see 
> the contents of the rational fields.
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/cf868bb9-c127-41b8-b86d-00e81a759fe6o%40googlegroups.com.

Reply via email to