{"id":"uglNbc28dI4","title":"Daml 101: Working with Numerical Values [2022]","description":"📚Check out Daml Learning Center: https://bit.ly/LearnDaml\n📖Join our forum and get started: https://bit.ly/tryDaml\n\nThis is a multi-episode series intended to take you from the brief context behind blockchain and smart contract to the development of smart contracts using a next-gen smart contract language called Daml. The entire series can be found here: https://bit.ly/damlone\n\nDaml is a development framework for creating systems of record that securely connect across business processes and data boundaries while retaining privacy, guaranteeing data integrity, and enforcing strict authorization. Allowing such systems to cross boundaries — legal, regulatory, organizational, or other — enables them to form seamless economic networks.\n\nDocs on working with numbers: https://docs.daml.com/daml/reference/working-with.html","channel_name":"Daml","published_at":"2022-03-07T00:00:00.000Z","thumbnail_url":"https://i.ytimg.com/vi/uglNbc28dI4/hqdefault.jpg","transcript_text":"numbers we all deal with numbers they mean an industry that doesn't involve numbers and put it in the comment below that's a total engagement date but if you disagree put it in the comments below and tell me why hi i'm steve sean in this video we're going to cover how to work with numerical values in demo stay tuned don't go anywhere did that work i saw it in the video somewhere numbers are important in our business in fact numbers are strange and almost magical in movies they would tell you how numbers is the language between the aliens and the humans and it's funny because numbers is the language between the business people and the technical people and mistakes on either side can have expensive consequences in demo there's several data types that are built in and we're going to cover a few of them to help you manage your numerical values and cover some of the fundamental operations that you would probably need let's take a closer look all right let's fire up the terminal and create a new project let's click numbers demo and we're going to use the template empty skeleton that cd into the folder and run demo studio now that fire is up vs code fantastic now there's no demo file so we're going to create one and we're going to save it as main dot demo let's make sure we save it into the right folder which is the demo folder let's call it main.demo just to make it easy all right let's uh let me just maximize the space here here we go and i'm going to create a um a template just to do a to do this demo uh don't look to this video as a any guide to writing great demo files or templates i just want to have something to be able to run this demo so we're going to call it a computation template and we're going to set the variables as well we're going to need a party so let's call the let's call the party the mathematician and some value that we want to test and we're going to try a couple of operations we're going to add by 1 we're going to subtract by 1. let's multiply by 2 and let's try a division and we'll try two we'll try division by three and we'll try a division by seven and it'll be clear why we're doing this in a second and the signatory will be just a mathematician we're not making this complicated and so the controller the mathematician can trigger a calculation and we just want to have a a way to invoke the calculations we'll just simply pass in a value to test and it's going to be an integer a whole number and what will we do well in the do block we are going to create a new contract out of this template and we'll perform a variety of computations ah let's add the modulus the the reminder the remainder i apologize the remainder so uh let's do add by one uh simply plus one remember that you cannot use a plus plus as you would in say javascript or net or java so we can use plus plus here likewise for subtraction it's simply value minus 1. multiplication is the familiar star operator there you go multiply by two and division no surprise there will be just a forward slash and we're going to do a division by seven as well and the mod of 5 will be the value percent sign which is a common use across different languages so that's good now let's write a simple script just to pass in a value to test and the first thing we want to do is to allocate a party let's think of a normal name let's say einstein for the mathematician fantastic and uh we're gonna kick off the the contract uh by just creating a to initialize a contract with just zeros and then we can call a choice to trigger command so we can see what we're doing so the first round i just copy and pasted a bunch of these input create arguments if you will and they're all zeroed out but we're gonna call a a choice we're gonna exercise a choice that will perform a calculation choice and we're going to pass a value i like 12 because it's divisible by a bunch of stuff let me show you a little trick here just drag it and until you see a halfway point on the left and now you can see the entire stretch you see that all the the computations have been made according to our do block so it's fantastic there's a few more computation like the power off and that we are going to need now the power of 2 is going to have to need a decimal data type which is really a numeric 10. numeric is another data type we can specify numeric followed by a number for the precision we're going to need square root as well square root we'll use decimal now in the do block let's add those two lines power of 2 we're going to take the value and raise it to the power of 2. but we can run into a problem it will say that it is doesn't recognize the star star operator this is because we have not imported the da.math library so let's go ahead and do that there's still a problem it tells us that the first number there is expected to be a numeric 10. so let's convert it to a decimal which is a numeric 10. so that should be fine and for that we just need to do a point zero and that should work now the square root as well we can take the val the square root which is sqrt but it doesn't like it so we're going to convert that to a decimal and that should do it down to the script we are going to add those two lines just to zero them out for our test remember to put the point zero because it is not an integer anymore it is a decimal so one thing that i forgot to mention is the division by seven the reason why is an integer is because we are reporting the quotient of the division uh so unlike what your calculator would tell you i hope that gave you a great overview of how to handle numerical values in demo when i used to teach kids how to code i love telling them the story of gangnam style in youtube gangnam style gangnam style gangnam style was a video that that first surpassed the 2 billionth view mark in youtube and when it did it broke the system and it resets it back to zero the reason why it hit a ceiling was because youtube was using a 32 bit integer now 32 bit would be 2 to the power 32 and you punch that into the calculator it should lend you around 4 billion now that is true but youtube was using a signed 32 bit which means we start counting at negative 2 billion and we max out at positive two billion two billion and change now they have since corrected it to use uh 64-bit integers but that was a very important lesson in understanding the data types that you're working with in any framework we got more content lined up see you next episode bye you","transcript_synced_at":"2026-10-26T04:09:40.468Z","segments":[{"start_seconds":0,"text":"numbers we all deal with numbers they mean an industry that doesn't involve numbers and put it in the comment below","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=0s"},{"start_seconds":11,"text":"that's a total engagement date but if you disagree put it in the comments below and tell me why hi i'm steve sean in this video we're","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=11s"},{"start_seconds":19,"text":"going to cover how to work with numerical values in demo stay tuned don't go anywhere","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=19s"},{"start_seconds":31,"text":"did that work i saw it in the video somewhere","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=31s"},{"start_seconds":43,"text":"numbers are important in our business in fact numbers are strange and almost magical","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=43s"},{"start_seconds":51,"text":"in movies they would tell you how numbers is the language between the aliens and the humans and it's funny because numbers is","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=51s"},{"start_seconds":60,"text":"the language between the business people and the technical people and mistakes on either side can have expensive consequences","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=60s"},{"start_seconds":69,"text":"in demo there's several data types that are built in and we're going to cover a few of them to help you manage your numerical values","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=69s"},{"start_seconds":77,"text":"and cover some of the fundamental operations that you would probably need let's take a closer","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=77s"},{"start_seconds":84,"text":"look all right let's fire up the terminal and create a new project let's click numbers demo and we're going","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=84s"},{"start_seconds":93,"text":"to use the template empty skeleton that cd into the folder and run demo","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=93s"},{"start_seconds":100,"text":"studio now that fire is up vs code fantastic","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=100s"},{"start_seconds":108,"text":"now there's no demo file so we're going to create one and we're going to save it as main dot demo","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=108s"},{"start_seconds":116,"text":"let's make sure we save it into the right folder which is the demo folder let's call it main.demo just to make it easy","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=116s"},{"start_seconds":124,"text":"all right let's uh let me just maximize the space here here we go and","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=124s"},{"start_seconds":131,"text":"i'm going to create a um a template just to do a to do this demo","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=131s"},{"start_seconds":138,"text":"uh don't look to this video as a any guide to writing great","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=138s"},{"start_seconds":145,"text":"demo files or templates i just want to have something to be able to run this demo so we're going to call it a computation","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=145s"},{"start_seconds":154,"text":"template and we're going to set the variables as","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=154s"},{"start_seconds":163,"text":"well we're going to need a party so let's call the let's call the party the mathematician and some value that we want to test and","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=163s"},{"start_seconds":171,"text":"we're going to try a couple of operations we're going to add by 1 we're going to subtract by 1.","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=171s"},{"start_seconds":178,"text":"let's multiply by 2 and let's try a division and we'll try two","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=178s"},{"start_seconds":185,"text":"we'll try division by three and we'll try a division by seven and it'll be clear why we're doing this in a second","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=185s"},{"start_seconds":193,"text":"and","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=193s"},{"start_seconds":195,"text":"the signatory will be just a mathematician we're not making this complicated and so the controller the mathematician","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=195s"},{"start_seconds":203,"text":"can trigger a calculation and we just want to have a a way to invoke the calculations","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=203s"},{"start_seconds":212,"text":"we'll just simply pass in a value to test and it's going to be an integer a whole number and what will we do well in the do block","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=212s"},{"start_seconds":221,"text":"we are going to create a new contract out of this template and we'll perform a variety of","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=221s"},{"start_seconds":229,"text":"computations ah let's add the modulus the the reminder","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=229s"},{"start_seconds":236,"text":"the remainder i apologize the remainder so uh let's do add by one uh simply","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=236s"},{"start_seconds":245,"text":"plus one remember that you cannot use a plus plus as you would in say javascript or net or java so we can use plus plus","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=245s"},{"start_seconds":254,"text":"here likewise for subtraction it's simply value minus 1.","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=254s"},{"start_seconds":262,"text":"multiplication is the familiar star operator there you go multiply by two","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=262s"},{"start_seconds":268,"text":"and division no surprise there will be just a forward slash and we're going to do a division by","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=268s"},{"start_seconds":276,"text":"seven as well and the mod of 5 will be","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=276s"},{"start_seconds":284,"text":"the value percent sign which is a common use across different languages so that's good now let's write a simple","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=284s"},{"start_seconds":293,"text":"script just to pass in a value to test and the first thing we want to do is to","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=293s"},{"start_seconds":300,"text":"allocate a party let's think of a normal name let's say einstein for the mathematician","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=300s"},{"start_seconds":309,"text":"fantastic and uh we're gonna kick off the the contract uh by just creating","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=309s"},{"start_seconds":316,"text":"a to initialize a contract with just zeros and then we can call a choice to trigger command so we can see what we're","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=316s"},{"start_seconds":324,"text":"doing so the first round i just copy and pasted a bunch of these input create arguments if you will and they're","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=324s"},{"start_seconds":331,"text":"all zeroed out but we're gonna call a a choice we're gonna exercise a choice that will perform a calculation","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=331s"},{"start_seconds":340,"text":"choice and we're going to pass a value i like 12 because it's divisible by a bunch of stuff","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=340s"},{"start_seconds":349,"text":"let me show you a little trick here just drag it and until you see a halfway point on the left and now you can see the entire stretch you see that","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=349s"},{"start_seconds":357,"text":"all the the computations have been made according to our do block so it's fantastic there's a few more computation","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=357s"},{"start_seconds":366,"text":"like the power off and that we are going to need now the power of 2 is going to have to","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=366s"},{"start_seconds":373,"text":"need a decimal data type which is really a numeric 10.","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=373s"},{"start_seconds":378,"text":"numeric is another data type we can specify numeric followed by a number for the precision we're going to need square root as well","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=378s"},{"start_seconds":386,"text":"square root we'll use decimal now in the do block let's add those two lines power of 2 we're going to take the value","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=386s"},{"start_seconds":394,"text":"and raise it to the power of 2.","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=394s"},{"start_seconds":397,"text":"but we can run into a problem it will say that it is doesn't recognize the star star operator this is because we","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=397s"},{"start_seconds":404,"text":"have not imported the da.math library so let's go ahead and do that there's still a problem it tells us that","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=404s"},{"start_seconds":412,"text":"the first number there is expected to be a numeric 10. so let's convert it to a decimal which is a numeric 10.","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=412s"},{"start_seconds":421,"text":"so that should be fine and for that we just need to do a point zero and that should work now the square root","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=421s"},{"start_seconds":429,"text":"as well we can take the val the square root which is sqrt but it doesn't like it so we're going to","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=429s"},{"start_seconds":437,"text":"convert that to a decimal and that should do it down to the script we are going to add those two lines just to zero them out","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=437s"},{"start_seconds":447,"text":"for our test remember to put the point zero because it is not an integer anymore it is a decimal so one thing that i forgot","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=447s"},{"start_seconds":456,"text":"to mention is the division by seven the reason why is an integer is because we are reporting the quotient of the division","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=456s"},{"start_seconds":463,"text":"uh so unlike what your calculator would tell you i hope that gave you a great overview of how to handle numerical values in demo","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=463s"},{"start_seconds":472,"text":"when i used to teach kids how to code i love telling them the story of gangnam style in youtube","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=472s"},{"start_seconds":479,"text":"gangnam style gangnam style gangnam style was a video that","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=479s"},{"start_seconds":486,"text":"that first surpassed the 2 billionth view mark in youtube and when it did it broke the system and","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=486s"},{"start_seconds":493,"text":"it resets it back to zero the reason why it hit a ceiling was because youtube was using a 32 bit","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=493s"},{"start_seconds":500,"text":"integer now 32 bit would be 2 to the power 32 and you punch that into the calculator it should lend you around 4 billion","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=500s"},{"start_seconds":510,"text":"now that is true but youtube was using a signed 32 bit which means we start counting at negative 2 billion and we","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=510s"},{"start_seconds":518,"text":"max out at positive two billion two billion and change now they have since corrected it to use","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=518s"},{"start_seconds":525,"text":"uh 64-bit integers but that was a very important lesson in understanding the data types that you're","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=525s"},{"start_seconds":532,"text":"working with in any framework we got more content lined up see you next episode","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=532s"},{"start_seconds":540,"text":"bye","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=540s"},{"start_seconds":563,"text":"you","url":"https://www.youtube.com/watch?v=uglNbc28dI4&t=563s"}],"youtube_url":"https://youtube.com/watch?v=uglNbc28dI4","url":"https://ccpedia.xyz/videos/uglNbc28dI4"}