Need a DataType which store data as Int, but also Decimal












0














i've got stuck with something about datatypes in mysql



i have the following table:



id (int,primary key),
tipo (varchar(45)),
inteiro_pedaco (varchar(45)),
marca (varchar(45)),
a (decimal(11,1),
b (decimal(11,1),
c (int (11))


the A and B column should store data with the following format: 00.0, 00.1, etc.



But, A and B column should also be able to store data as if it was INT, not only decimal, however, if i try to put "10" for example, it automaticaly gets formated to "10.0"



The biggest problem is: those two columns (A and B) HAS to store 10 as value and other times 10.0, even if 10.0 is equal to 10, it has to be stored exactly the way it was sent, with or without the decimal. If the input was 10, it has to be stored as 10, if it was 10.0, it has to be 10.0



And i know that may sounds weird, but believe me, it will receive data as 10.0 sometimes, i wasn't using the 10.0 as example, it will REALLY receive data as 10.0 and 10



I tried reading about datatypes, but i could find none who fufil those requirements, except varchar, but i cant use varchar in this case, also, i cant make two separetely colunms to store the data, they gotta be in the same column



I was thinking about saving everything as decimal, and them formating it when doing a select, but in that case, i would have to make a new colunm just to store if it is decimal or not



So, there is any kinda of datatype who fits in the description above? If not, is formating the only way to do what i want?



Thanks for the help










share|improve this question
























  • Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
    – Gordon Linoff
    Nov 12 at 17:11










  • Try float Data type
    – saravanatn
    Nov 12 at 17:14










  • only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
    – Kouhei
    Nov 12 at 17:20












  • @saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
    – Kouhei
    Nov 12 at 17:23










  • I didn't know there's any difference between 10 and 10.0?
    – dnoeth
    Nov 12 at 17:31
















0














i've got stuck with something about datatypes in mysql



i have the following table:



id (int,primary key),
tipo (varchar(45)),
inteiro_pedaco (varchar(45)),
marca (varchar(45)),
a (decimal(11,1),
b (decimal(11,1),
c (int (11))


the A and B column should store data with the following format: 00.0, 00.1, etc.



But, A and B column should also be able to store data as if it was INT, not only decimal, however, if i try to put "10" for example, it automaticaly gets formated to "10.0"



The biggest problem is: those two columns (A and B) HAS to store 10 as value and other times 10.0, even if 10.0 is equal to 10, it has to be stored exactly the way it was sent, with or without the decimal. If the input was 10, it has to be stored as 10, if it was 10.0, it has to be 10.0



And i know that may sounds weird, but believe me, it will receive data as 10.0 sometimes, i wasn't using the 10.0 as example, it will REALLY receive data as 10.0 and 10



I tried reading about datatypes, but i could find none who fufil those requirements, except varchar, but i cant use varchar in this case, also, i cant make two separetely colunms to store the data, they gotta be in the same column



I was thinking about saving everything as decimal, and them formating it when doing a select, but in that case, i would have to make a new colunm just to store if it is decimal or not



So, there is any kinda of datatype who fits in the description above? If not, is formating the only way to do what i want?



Thanks for the help










share|improve this question
























  • Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
    – Gordon Linoff
    Nov 12 at 17:11










  • Try float Data type
    – saravanatn
    Nov 12 at 17:14










  • only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
    – Kouhei
    Nov 12 at 17:20












  • @saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
    – Kouhei
    Nov 12 at 17:23










  • I didn't know there's any difference between 10 and 10.0?
    – dnoeth
    Nov 12 at 17:31














0












0








0







i've got stuck with something about datatypes in mysql



i have the following table:



id (int,primary key),
tipo (varchar(45)),
inteiro_pedaco (varchar(45)),
marca (varchar(45)),
a (decimal(11,1),
b (decimal(11,1),
c (int (11))


the A and B column should store data with the following format: 00.0, 00.1, etc.



But, A and B column should also be able to store data as if it was INT, not only decimal, however, if i try to put "10" for example, it automaticaly gets formated to "10.0"



The biggest problem is: those two columns (A and B) HAS to store 10 as value and other times 10.0, even if 10.0 is equal to 10, it has to be stored exactly the way it was sent, with or without the decimal. If the input was 10, it has to be stored as 10, if it was 10.0, it has to be 10.0



And i know that may sounds weird, but believe me, it will receive data as 10.0 sometimes, i wasn't using the 10.0 as example, it will REALLY receive data as 10.0 and 10



I tried reading about datatypes, but i could find none who fufil those requirements, except varchar, but i cant use varchar in this case, also, i cant make two separetely colunms to store the data, they gotta be in the same column



I was thinking about saving everything as decimal, and them formating it when doing a select, but in that case, i would have to make a new colunm just to store if it is decimal or not



So, there is any kinda of datatype who fits in the description above? If not, is formating the only way to do what i want?



Thanks for the help










share|improve this question















i've got stuck with something about datatypes in mysql



i have the following table:



id (int,primary key),
tipo (varchar(45)),
inteiro_pedaco (varchar(45)),
marca (varchar(45)),
a (decimal(11,1),
b (decimal(11,1),
c (int (11))


the A and B column should store data with the following format: 00.0, 00.1, etc.



But, A and B column should also be able to store data as if it was INT, not only decimal, however, if i try to put "10" for example, it automaticaly gets formated to "10.0"



The biggest problem is: those two columns (A and B) HAS to store 10 as value and other times 10.0, even if 10.0 is equal to 10, it has to be stored exactly the way it was sent, with or without the decimal. If the input was 10, it has to be stored as 10, if it was 10.0, it has to be 10.0



And i know that may sounds weird, but believe me, it will receive data as 10.0 sometimes, i wasn't using the 10.0 as example, it will REALLY receive data as 10.0 and 10



I tried reading about datatypes, but i could find none who fufil those requirements, except varchar, but i cant use varchar in this case, also, i cant make two separetely colunms to store the data, they gotta be in the same column



I was thinking about saving everything as decimal, and them formating it when doing a select, but in that case, i would have to make a new colunm just to store if it is decimal or not



So, there is any kinda of datatype who fits in the description above? If not, is formating the only way to do what i want?



Thanks for the help







sql mysql-workbench sqldatatypes






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 16:42









Gordon Linoff

756k35291399




756k35291399










asked Nov 12 at 16:40









Kouhei

104




104












  • Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
    – Gordon Linoff
    Nov 12 at 17:11










  • Try float Data type
    – saravanatn
    Nov 12 at 17:14










  • only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
    – Kouhei
    Nov 12 at 17:20












  • @saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
    – Kouhei
    Nov 12 at 17:23










  • I didn't know there's any difference between 10 and 10.0?
    – dnoeth
    Nov 12 at 17:31


















  • Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
    – Gordon Linoff
    Nov 12 at 17:11










  • Try float Data type
    – saravanatn
    Nov 12 at 17:14










  • only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
    – Kouhei
    Nov 12 at 17:20












  • @saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
    – Kouhei
    Nov 12 at 17:23










  • I didn't know there's any difference between 10 and 10.0?
    – dnoeth
    Nov 12 at 17:31
















Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
– Gordon Linoff
Nov 12 at 17:11




Your data seems very confused. Either the value is a number, and the trailing zeros don't matter. Or the value is a string, and arithmetic doesn't really make sense. What does the value contain?
– Gordon Linoff
Nov 12 at 17:11












Try float Data type
– saravanatn
Nov 12 at 17:14




Try float Data type
– saravanatn
Nov 12 at 17:14












only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
– Kouhei
Nov 12 at 17:20






only numbers will be stored, however, neither i like this way of storing data, unfortunally, i dont have much of a choice because i just follow what people tell me to do. I gotta say, i suck at math, my boss tried to explain to me why this had to be this way, but i didnt get it at all, and he doesnt understand much of programming (in my case, i still learning, im just a trainee), so i tought i could try to check if it was possible, but by what it looks like, i think ill have to get in touch with my boss again and see what we will do, and try to explain him why this isn't possible
– Kouhei
Nov 12 at 17:20














@saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
– Kouhei
Nov 12 at 17:23




@saravanatn, i tried float, but it didnt worked, also, when typing big numbers, it turned into a mess, when i inputed 1234567890.0 it was saved as a completely different number
– Kouhei
Nov 12 at 17:23












I didn't know there's any difference between 10 and 10.0?
– dnoeth
Nov 12 at 17:31




I didn't know there's any difference between 10 and 10.0?
– dnoeth
Nov 12 at 17:31












3 Answers
3






active

oldest

votes


















0














You might want to consider having multiple columns. eg DEC_VAL, INT_VAL, STR_VAL



This will solve join issues and filter issues but is slightly harder to maintain.






share|improve this answer





















  • it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
    – Kouhei
    Nov 12 at 16:51












  • because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
    – Kouhei
    Nov 12 at 16:55





















0














Sounds like the problem is when you get the data as opposed to how it's stored, if the decimal point is throwing things off (like you want a certain appearance during output) maybe try a case statement for the select.



select case when cast(cast(A as int) as decimal) = A then cast(A as int) else A end


What we are doing here is testing if column A as an int is equal to column A as a decimal, and if they are the same we are casting it as an int. If they are not equal we leave column A as a decimal.



As the others noted this is kind of an odd problem, because most things will evaluate 1.0 = 1, but I'm guessing this is formatting for the output as opposed to a logical evaluation down the line. Anyway hope this helps :)






share|improve this answer





















  • This will not work as CASE returns a single datatype, in this case a DECIMAL.
    – dnoeth
    Nov 12 at 17:39










  • if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
    – Kouhei
    Nov 12 at 17:45



















0














If trailing or leading variables are important, then you should store the vaue as a string. You really do not have much choice.



Basically, the value is not a number, it is some sort of code. In the world of numbers, 10.0 is equal to 10.



EDIT:



Based on your comment, you should have two columns that are both integers. One is for "the part before the decimal point" the second is for the range.



You are making a mistake by trying to put two things in one column.






share|improve this answer























  • if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
    – Kouhei
    Nov 12 at 16:51






  • 1




    @Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
    – Gordon Linoff
    Nov 12 at 17:14











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266505%2fneed-a-datatype-which-store-data-as-int-but-also-decimal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You might want to consider having multiple columns. eg DEC_VAL, INT_VAL, STR_VAL



This will solve join issues and filter issues but is slightly harder to maintain.






share|improve this answer





















  • it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
    – Kouhei
    Nov 12 at 16:51












  • because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
    – Kouhei
    Nov 12 at 16:55


















0














You might want to consider having multiple columns. eg DEC_VAL, INT_VAL, STR_VAL



This will solve join issues and filter issues but is slightly harder to maintain.






share|improve this answer





















  • it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
    – Kouhei
    Nov 12 at 16:51












  • because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
    – Kouhei
    Nov 12 at 16:55
















0












0








0






You might want to consider having multiple columns. eg DEC_VAL, INT_VAL, STR_VAL



This will solve join issues and filter issues but is slightly harder to maintain.






share|improve this answer












You might want to consider having multiple columns. eg DEC_VAL, INT_VAL, STR_VAL



This will solve join issues and filter issues but is slightly harder to maintain.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 16:44









Hogan

54.4k864102




54.4k864102












  • it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
    – Kouhei
    Nov 12 at 16:51












  • because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
    – Kouhei
    Nov 12 at 16:55




















  • it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
    – Kouhei
    Nov 12 at 16:51












  • because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
    – Kouhei
    Nov 12 at 16:55


















it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
– Kouhei
Nov 12 at 16:51






it dont solve the problem because i cant have more than 3 colums for dimensions. A, B and C are used for almost everything. When "tipo" colunm is "tubo" for example, "A" will be external diameter and "B" internal diameter, but in case "tipo" column is "placa", "A" will be width and "B" thickness
– Kouhei
Nov 12 at 16:51














because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
– Kouhei
Nov 12 at 16:55






because i cant figure out how to solve this problem, i came here looking for help and maybe a solution. in case i cant find an way out, i think ill just have to set up a meeting with my boss
– Kouhei
Nov 12 at 16:55















0














Sounds like the problem is when you get the data as opposed to how it's stored, if the decimal point is throwing things off (like you want a certain appearance during output) maybe try a case statement for the select.



select case when cast(cast(A as int) as decimal) = A then cast(A as int) else A end


What we are doing here is testing if column A as an int is equal to column A as a decimal, and if they are the same we are casting it as an int. If they are not equal we leave column A as a decimal.



As the others noted this is kind of an odd problem, because most things will evaluate 1.0 = 1, but I'm guessing this is formatting for the output as opposed to a logical evaluation down the line. Anyway hope this helps :)






share|improve this answer





















  • This will not work as CASE returns a single datatype, in this case a DECIMAL.
    – dnoeth
    Nov 12 at 17:39










  • if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
    – Kouhei
    Nov 12 at 17:45
















0














Sounds like the problem is when you get the data as opposed to how it's stored, if the decimal point is throwing things off (like you want a certain appearance during output) maybe try a case statement for the select.



select case when cast(cast(A as int) as decimal) = A then cast(A as int) else A end


What we are doing here is testing if column A as an int is equal to column A as a decimal, and if they are the same we are casting it as an int. If they are not equal we leave column A as a decimal.



As the others noted this is kind of an odd problem, because most things will evaluate 1.0 = 1, but I'm guessing this is formatting for the output as opposed to a logical evaluation down the line. Anyway hope this helps :)






share|improve this answer





















  • This will not work as CASE returns a single datatype, in this case a DECIMAL.
    – dnoeth
    Nov 12 at 17:39










  • if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
    – Kouhei
    Nov 12 at 17:45














0












0








0






Sounds like the problem is when you get the data as opposed to how it's stored, if the decimal point is throwing things off (like you want a certain appearance during output) maybe try a case statement for the select.



select case when cast(cast(A as int) as decimal) = A then cast(A as int) else A end


What we are doing here is testing if column A as an int is equal to column A as a decimal, and if they are the same we are casting it as an int. If they are not equal we leave column A as a decimal.



As the others noted this is kind of an odd problem, because most things will evaluate 1.0 = 1, but I'm guessing this is formatting for the output as opposed to a logical evaluation down the line. Anyway hope this helps :)






share|improve this answer












Sounds like the problem is when you get the data as opposed to how it's stored, if the decimal point is throwing things off (like you want a certain appearance during output) maybe try a case statement for the select.



select case when cast(cast(A as int) as decimal) = A then cast(A as int) else A end


What we are doing here is testing if column A as an int is equal to column A as a decimal, and if they are the same we are casting it as an int. If they are not equal we leave column A as a decimal.



As the others noted this is kind of an odd problem, because most things will evaluate 1.0 = 1, but I'm guessing this is formatting for the output as opposed to a logical evaluation down the line. Anyway hope this helps :)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 12 at 17:15









Randall

999516




999516












  • This will not work as CASE returns a single datatype, in this case a DECIMAL.
    – dnoeth
    Nov 12 at 17:39










  • if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
    – Kouhei
    Nov 12 at 17:45


















  • This will not work as CASE returns a single datatype, in this case a DECIMAL.
    – dnoeth
    Nov 12 at 17:39










  • if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
    – Kouhei
    Nov 12 at 17:45
















This will not work as CASE returns a single datatype, in this case a DECIMAL.
– dnoeth
Nov 12 at 17:39




This will not work as CASE returns a single datatype, in this case a DECIMAL.
– dnoeth
Nov 12 at 17:39












if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
– Kouhei
Nov 12 at 17:45




if i understood correctly, it wouldn't work, because if for example A have 10.0 stored and is tested as int (10) if it is equal to A as decimal, it would be understood as true, right? then the output would be 10, but the .0 cant be ignored, well... i dont say i said something stupid (im still learning, so, forgive me hehe)
– Kouhei
Nov 12 at 17:45











0














If trailing or leading variables are important, then you should store the vaue as a string. You really do not have much choice.



Basically, the value is not a number, it is some sort of code. In the world of numbers, 10.0 is equal to 10.



EDIT:



Based on your comment, you should have two columns that are both integers. One is for "the part before the decimal point" the second is for the range.



You are making a mistake by trying to put two things in one column.






share|improve this answer























  • if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
    – Kouhei
    Nov 12 at 16:51






  • 1




    @Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
    – Gordon Linoff
    Nov 12 at 17:14
















0














If trailing or leading variables are important, then you should store the vaue as a string. You really do not have much choice.



Basically, the value is not a number, it is some sort of code. In the world of numbers, 10.0 is equal to 10.



EDIT:



Based on your comment, you should have two columns that are both integers. One is for "the part before the decimal point" the second is for the range.



You are making a mistake by trying to put two things in one column.






share|improve this answer























  • if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
    – Kouhei
    Nov 12 at 16:51






  • 1




    @Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
    – Gordon Linoff
    Nov 12 at 17:14














0












0








0






If trailing or leading variables are important, then you should store the vaue as a string. You really do not have much choice.



Basically, the value is not a number, it is some sort of code. In the world of numbers, 10.0 is equal to 10.



EDIT:



Based on your comment, you should have two columns that are both integers. One is for "the part before the decimal point" the second is for the range.



You are making a mistake by trying to put two things in one column.






share|improve this answer














If trailing or leading variables are important, then you should store the vaue as a string. You really do not have much choice.



Basically, the value is not a number, it is some sort of code. In the world of numbers, 10.0 is equal to 10.



EDIT:



Based on your comment, you should have two columns that are both integers. One is for "the part before the decimal point" the second is for the range.



You are making a mistake by trying to put two things in one column.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 12 at 17:16

























answered Nov 12 at 16:43









Gordon Linoff

756k35291399




756k35291399












  • if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
    – Kouhei
    Nov 12 at 16:51






  • 1




    @Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
    – Gordon Linoff
    Nov 12 at 17:14


















  • if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
    – Kouhei
    Nov 12 at 16:51






  • 1




    @Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
    – Gordon Linoff
    Nov 12 at 17:14
















if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
– Kouhei
Nov 12 at 16:51




if storing as a string, when needed to do some math operations, wont be there some kinda of problem? puting it on a simple way, the number after the dot will be used in two ways, which is defined by the "tipo" colunm. The first way is: the number before the dot will be applied into some calculation and the number after the dot will define its range. The second way, when the "tipo" colunm does not match a specified condition, the entire number will be used for a calculation, even the number after the dot
– Kouhei
Nov 12 at 16:51




1




1




@Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
– Gordon Linoff
Nov 12 at 17:14




@Kouhei . . . The string value will be (silently) converted to a number for the operation. But you seem to have other problems.
– Gordon Linoff
Nov 12 at 17:14


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53266505%2fneed-a-datatype-which-store-data-as-int-but-also-decimal%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python